Hi members,
I need to report a reset reason and am required to differentiate brown-out reset and power-on-reset.
machine.reset_cause() seems to return only
0: SOFT_RESET
1: PWRON_RESET
2: HARD_RESET
3: WDT_RESET
4: DEEPSLEEP_RESET
Is there any way to tell brown-out?
Any comments will be very helpful to me.
Thanks in advance.
how to differentiate brown out reset (BOR) and power-on-reset(POR)
- blackwendy21
- Posts: 2
- Joined: Wed Oct 02, 2019 1:04 am
Re: how to differentiate brown out reset (BOR) and power-on-reset(POR)
This is not possible with the current firmware. This looks like possibly just an oversight in stm32/modmachine.c.
So if BORRSTF is set, you'll get SOFT rather than POWER_ON for a BOR. I guess it would be easy enough to add another case for BORRSTF?
Code: Select all
// get reset cause from RCC flags
uint32_t state = RCC->RCC_SR;
if (state & RCC_SR_IWDGRSTF || state & RCC_SR_WWDGRSTF) {
reset_cause = PYB_RESET_WDT;
} else if (state & RCC_SR_PORRSTF
#if !defined(STM32F0)
|| state & RCC_SR_BORRSTF
#endif
) {
reset_cause = PYB_RESET_POWER_ON;
} else if (state & RCC_SR_PINRSTF) {
reset_cause = PYB_RESET_HARD;
} else {
// default is soft reset
reset_cause = PYB_RESET_SOFT;
}
- blackwendy21
- Posts: 2
- Joined: Wed Oct 02, 2019 1:04 am
Re: how to differentiate brown out reset (BOR) and power-on-reset(POR)
Thank you so much, Jimmo.
I will try this.
Fortunately, my client agreed to eliminate brown-out reset cause reporting requirement because of non-portability when using this kind of hardware specific solution.
However, out of my curiosity I will try your suggestion later.
Once again thank you.
Kind Regards,
Wendy
I will try this.
Fortunately, my client agreed to eliminate brown-out reset cause reporting requirement because of non-portability when using this kind of hardware specific solution.
However, out of my curiosity I will try your suggestion later.
Once again thank you.
Kind Regards,
Wendy