I have enabled multiple interrupt sources to wakeup my LPC54102 from sleep, deep-sleep and power-down mode.
In the main loop I power down the microcontroller. What happens, if an interrupt fires, while the power-down instructions are executed?
main: I switch the main clock to 32kHz RTC bevor powering down. (Is this necessary? I want to wakeup from RTC and PININT)
Interrupt (PININT): fires, switches main clock back to IRC, handle data, finishes
main: power down (RTC no longer the main clock source, since switched back to IRC in interrupt)
Is this a problem?
I think not, but my microcontroller sometimes got frozen up with 696uA. Doing nothing, can not attach debugger.
The error happens very rarely. In time intervals of some minutes to some hours.
I think it is no option, to set only a flag in the interrupt routine and handle the flag in the main loop. Because if the CPU is powering down while the interrupt happens, the flag will be handled only the next time, the CPU wakes up. However, the flag should force code to be executed immediately!