There are a number of possible causes for a microcontroller to reset itself, for example:
brown-out or power-out
reset initiated from software (to programmatically enter bootloader, etc)
I'm wondering if there is a way to figure out, when a microcontroller starts up, what was the reason for the last reset - perhaps using some kind of flags that survive reset. In particular I'm on the MSP430F5xxx series.
The use case is to avoid a cycle where some part of the self-test routine (for example) causes a glitch on the power rail, and then the micro resets itself and runs the self test again, repeat (until it succeeds).