Michael Ranas

how to get stack pointer (SP)

Discussion created by Michael Ranas on Jul 28, 2008
Latest reply on Jul 29, 2008 by Michael Ranas
can you help me get the value of the stack pointer?
i am working on a module where I would monitor the value of the stack pointer and the program counter upon access violation.
I have this code in my interrupt handler:
    ISR void CPU12MPU_ISR(void) {
        __asm sts u16sp 
        __asm movw 8,SP,u16pc
The problem with this code was it will have an endless loop executing __asm sts u16sp.
Is there any way I could get the value of SP?