Program startup method

Can we tell (within the program) whether the processor has been started manually from the debugger or automatically via the autorun flag? Looks like we can define an output to a default off or on state regardless of how the program was started. That doesn’t quite do what I need.

I would like to handle startup of digital outputs differently depending on if the program was started manually or automatically (ie. after a power cycle). For example, if I start the program manually after making some program edits, I would want outputs to stay in last-state until program logic makes changes. If the program starts automatically after power outage, I want outputs to start in off-state until program logic makes changes.

Isn’t this the default behavior? If a board loses power, won’t the outputs be off when it is powered back up until they are told otherwise?

To check if the program started from the debugger or not, you could monitor the seconds or elapsed time since power up in the memory map (0xF030010C or 0xF0300160) These values will roll over so you need to check for that by saving the last value in a persistent variable and comparing to see if it suddenly changed due to a restart. You could probably do something with the powerup flag as well, but then you may not know if the power failed the next time you debug if your program clears that.