Hi xiaohui,
Could you please specify how you test whether MCU wake-up or not?
I shortly look at your code and I cannot see any wake-up signal (like GPIO pin toggling) in your main loop - all unconditioned commands do not contain and any commands for outside visible signal.
Maybe I just miss something.
The typical way how we detect stop/run mode is power consumption measurement, but the run mode may be sometimes missed when wake-up execution time is enough short.
The next and more reliable way of stop/run mode detection is watching ECLK signal by an oscilloscope. In that case, we have to enable ECLK signal in normal mode by ECLKCTL_NECLK=0; command.
Note: You use full stop mode and the first command after wake-up may be CAN_send() function. You don’t wait for the start of crystal/oscillator oscillation. So, there may be also a potential issue with CAN clock specification. I would like to recommend wait for UPOSC flag (until oscillator clock will be validated) first.
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!
-----------------------------------------------------------------------------------------------------------------------