Question

I want to know what was the last instruction being executed in the program line just before an interrupt has been caught. It seems that reading the microcontroller stack is not possible.

Was it helpful?

Solution

It is not possible on a PIC16, because the hardware stack is not accessible to software. It is, however, possible to access the hardware stack on the PIC18. The application note Manipulating the Stack of the PIC18 Microcontroller is a good reference.

If you only want to see the PCL value pushed onto the stack when the interrupt was called, then you only have to read the TOSU, TOSH and TOSL registers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top