Hi Byeongjin,
Since you wrote about sleep mode, I suppose that you question is related to MSCAN module.
The PE have an option for CAN Wakeup, but this option just affects WUPE and WUPM bits configuration. No specific code is generated.
Please look at attached simple example code for CAN wake-up.
Note: this example code was created for older S12XE MCU, but the MSCAN module is still the same.
The important code is:
//============
CANCTL0_WUPE = 1; //wake up enable
CANRIER_WUPIE = 1; //wake up interrupt enable
//============
and:
CANCTL0_SLPRQ = 1; //sleep mode request
while(CANCTL1_SLPAK == 0); //wait for acknowledge of sleep mode
asm ANDCC #0x7F; //clear S bit
asm nop;
asm STOP; //STOP mode
You should also create a wake-up ISR like:
interrupt VectorNumber_Vcan0wkup void CAN_WAKE(void)
{
//your code
CANRFLG=0x80 //clear WUPIF flag
CANRIER_WUPIE = 0; //wake up interrupt disable
}
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------