Hi xiaohui,
Your code contains CAN0CTL1_BORM=0; command. That means that only way how the MSCAN module may leave the bus-off state is when the module detects 128 occurrences of 11 consecutive recessive bits.
If you want to use CAN bus-off recovery upon user request (CAN0MISC_BOHOLD = 0x01;), you have to enable that feature by setting BORM bit in a CANCTL1 register.
According to your second thread, you want to use stop mode. I would like to recommend switch MSCAN module into sleep mode prior entering to MCU stop mode. This will prevent against generating error frames on the CAN bus due to unexpected stop mode.
Please use commands below prior entering into stop mode.
CAN0CTL0_SLPRQ = 1; //sleep mode request
while(CAN0CTL1_SLPAK == 0); //wait for acknowledge of sleep mode
This will manage that MCU will finish all scheduled frames in TX buffers and waits until receiving frame ends (it wait for bus idle).
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!
-----------------------------------------------------------------------------------------------------------------------