Hi Katrinal,
when MCU wake-up from stop mode, the CPU executes ISR and after that, it returns on next instruction just below STOP instruction.
Note: the STOP instruction must not be executed from ISR (where I-bit is set and MCU cannot wake-up by I-bit maskable interrupts).
See attached example code for CAN wake-up from stop mode (for S12XE).
commands for enable CAN wake-up (inside CAN init function):
CANCTL0_WUPE = 1;
CANRIER_WUPIE = 1;
commands for go to sleep (somewhere in main() function):
CANCTL0_SLPRQ = 1;
while(CANCTL1_SLPAK == 0);
asm ANDCC #0x7F;
asm nop;
asm STOP;
example of CAN wake-up test ISR:
#pragma CODE_SEG NON_BANKED
interrupt VectorNumber_Vcanwkup void CAN_WAKE(void)
{
while(1){
for(i=0; i<50000; i++){
asm nop;
}
}
}
#pragma CODE_SEG DEFAULT
We have to enter CAN sleep mode (it waits until all Tx buffers are empty and current Rx transfer finish) before MCU STOP instruction execution for avoiding generating invalid messages on CAN bus.
I hope it helps you.
Radek