| Electronics > Beginners |
| Sorry to interrupt ... |
| << < (7/7) |
| PerranOak:
Cheers both. What a noble but gassy bunch we are! |
| dnwheeler:
Probably the biggest issue to consider is that you don't really know what code was being interrupted. For example, the code may have been in the middle of interacting with some external device, or reconfiguring several hardware registers, or clocking out a series of data values, etc. If an interrupt occurs and you don't return from it, some hardware could be left in an "in-between" state. Lights could be left on, devices could get stuck on/off, allocated memory may not be freed, etc. |
| mikerj:
--- Quote from: langwadt on June 01, 2018, 08:34:04 am --- --- Quote from: mikerj on June 01, 2018, 08:23:09 am --- The 14 bit PIC has a hardware stack purely for return addresses, it's not used to save or pass data between functions. --- End quote --- so the main loop could call functions so there are addresses on the stack that will never get popped if you just straight to a different place in main? --- End quote --- Exactly. This is why you would need to manually pop the last address off the stack if you were going to jump out of the ISR, rather than returning. |
| langwadt:
--- Quote from: mikerj on June 04, 2018, 09:00:36 am --- --- Quote from: langwadt on June 01, 2018, 08:34:04 am --- --- Quote from: mikerj on June 01, 2018, 08:23:09 am --- The 14 bit PIC has a hardware stack purely for return addresses, it's not used to save or pass data between functions. --- End quote --- so the main loop could call functions so there are addresses on the stack that will never get popped if you just straight to a different place in main? --- End quote --- Exactly. This is why you would need to manually pop the last address off the stack if you were going to jump out of the ISR, rather than returning. --- End quote --- that would get rid of the address pushed by entering the interrupt, what if the main loop just pushed an address on the stack to call another function? |
| Navigation |
| Message Index |
| Previous page |