2025-02-11 02:28 AM
Some strange behaviour that I can't explain but like to understand :
I am using an e-paper display via SPI, and to conserve power during sleep, I power down the display via a FET.
After waking up, I enable the power to the display, then initialize the SPI to talk to it.
gpio::enableGpio(gpio::group::enableDisplayPower);
MX_SPI2_Init();
gpio::enableGpio(gpio::group::spiDisplay);
If I add a 1ms delay between turning on the power to the display and enabling the SPI, then the hard fault never appears..
gpio::enableGpio(gpio::group::enableDisplayPower);
HAL_Delay(1);
MX_SPI2_Init();
gpio::enableGpio(gpio::group::spiDisplay);
Of course, if I debug/step through MX_SPI2_Init(); the hard fault doesn't appear as this is also adding delays..
Any idea what is going wrong or how I could further investigate ?
Solved! Go to Solution.
2025-02-11 05:13 AM
This is apparently due to a power glitch caused by the inrush current of the display.
I can't really see it on the scope, but if I enable the power slowly (avoiding the inrush current), then the hard fault does not occur.
2025-02-11 05:13 AM
This is apparently due to a power glitch caused by the inrush current of the display.
I can't really see it on the scope, but if I enable the power slowly (avoiding the inrush current), then the hard fault does not occur.
2025-02-11 07:12 AM
Maybe one more question here :
is it possibe to somehow 'see' trace in the MCU that a brown-out happened ? If possible, I could add that to the NMI / HardFault handlers and confirm my assumptions.
2025-02-11 11:29 AM
I've found there is a BOR_RSTF (BrownOut Reset Flag) in the RCC_CSR, however, I'm not experiencing a reset but rather a NMI or Hard Fault...