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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top