Correct use of Context save with 2 level interrupts

Started by TimB, May 10, 2021, 02:30 PM

Previous topic - Next topic

TimB


This I think may be best answered by Les but if anyone else knows please let me know.

In the past I would do all my context saving myself. Look at the asm generated for my code and then save the system vars and SFRs

However since Les implemented Context Save and Context Restore I know its taken care of at least once.

But how to handle 2 level interrupt code. I know the Pic will do basic context saving, So I think its Context save in the low level and manage my own in the higher level code.

Any Pointers on correct method appreciated.

Tim


top204

Just add Context Save and Context Restore in both the high and low level interrupt handlers, or in a low level handler or a high level handler.

The compiler knows what name is associated with a high or low interrupt, so it will store its contexts in seperate, internal, arrays. You can see the internal arrays in the assembler listing becuase they are named accordingly for clarity to the user.

Just wait until you see and use the Interrupt Manager library for the Positron board, or any PIC18FxxK42 device. It makes interrupts so easy. :-)