The STM32F4 MCU has a brownout reset feature. According to the manual, section 5.2.2, when the supply voltage VDD drops below the selected VBOR threshould, a device reset is generated. After reset, I can check the BORRSTF flag in register RCC_CSR (see section 6.3.21 of the manual) to see whether the reset was due to a brownout.
I'd like to simulate this behavior in the STM32F100, which lacks a brownout reset feature. My idea is to use the programmable voltage detector (section 4.2.2 in the manual) to generate an interrupt in EXTI line 16. When the interrupt handler is called, I'll generate a software reset; I can verify, after reset, that the reason was a software reset by way of the SFTRSTF flag in register RCC_CSR (see section 6.3.10 of the manual). Since I don't generate a software reset anywhere else in my code, I can be certain it was due to a brownout.
Here's what I'm looking to know:
- Can anyone see a flaw in this idea?
- Would an actual brownout wipe the SFTRSTF flag in question?