I'm using a MK22F512FN12 chip on a custom boards. The micro controller needs to go into a low power state and wakeup with one of 2 pin interrupts. It also uses the kinetis flash loader to be able to update via USB. I've gotten the device to go into low power and even wake up from low power. The issue is it seems to take two interrupts to fully bring up the application firmware.
- Go into low power mode.
- Press button, observe an increase in current
- Press button again, the device runs the main application code
In the flash loader, I have a check to look at a byte in flash to see if its has a certain value to either fall into flash loader or jump to the application. (This is so you can launch the flash loader from the application.) If it goes into the flash loader and someone doesn't want to update the device they also need to be able to exit the boot loader with the button press rather than updating the device. There is a LED that is supposed to turn on to indicate when the device is in flash loader.
What I think is happening after the first button press the application wakes up and runs through the flash loader check code, but I don't see the flash loader LED turn on. I'm not doing any handling of low wake up bits in the interrupt, so I was thinking this might cause some fault in how the code runs. But, it's still able to check the button to exit the boot loader.
My main question is: Is there special handling of low wake up bits that you have to do in the flash loader when the device wakes up? Because I know after reset it starts with the flash loader code before it loads the application.
Any ideas or clarifications needed? Thanks!