UbuntuPath
UbuntuPath

Reputation: 33

How to get the value of Program Counter from Stack on PIC18F

I am trying to understand multitasking in PIC18Fs. I know that program counter is stored in Stack before interrupts and then it returns to the same PC address when interrupt finishes. How can I find the PC value stored in Stack and save it in some register so that I can use it later to return to. ?e.g PC value for Task1,Task2 etc.

Upvotes: 0

Views: 132

Answers (1)

UbuntuPath
UbuntuPath

Reputation: 33

I think AN818 Answers my question . SO in a pre-emptive OS, I would save the TOSU,TOSL,TOSH and STKPTR (along with other registers) just before executing ISR and from ISR load TOSU,TOSL,TOSH and STKPTR with new value for the next task. Would welcome any further comment/suggestion/example on this. Thanks

Upvotes: 0

Related Questions