embeddedstm32resetclocksystem-clock

Flags getting randomly set in RCC(Reset and Clock Control register) on Power On


I am working on MM32Spin05 MCU. After power on, all 6 flags in the RCC(Reset and Clock Control) register are getting set. After a reset, the default value of this register should be 0X XC000000. But I am observing it as 0X FC000000. I am not doing anything with respect to the watchdog timers, or the low power module or the s/w reset.

I have a requirement, that, if a software reset is done, a certain page in the flash memory is to be cleared. But on boot up, the flag is set for reasons unknown to me and hence, the flash memory page is getting cleared. I am actually doing a Power Reset. I am turning off and then turning on the power supply to the MCU. On boot-up, the Software Reset flag is set and hence, according to my code, it is triggering the flash memory page erase. The Flash memory page should be erased ONLY on a software reset, not a power reset. Immediately after the MCU boots up, I print the RCC_CSR Register value, and see that all 6 flags are set.

LPWRRSTF: Low power reset flag
WDGRSTF: Window watchdog reset flag
IWDGRSTF: Independent watchdog reset flag
SFTRSTF: Software reset flag
PORRSTF: POR/PDR reset flag
PINRSTF: PIN reset flag

I am confused, as to why, a power reset is causing the software reset flag to set?

I am stuck on this for more than a week and am fully clueless about it. Any help or suggestions would be highly welcome. Thanks in Advance

bits in the RCC Register


Solution

  • As the manual says, the top 4 bits are "don't care" on power-on (or pin) reset, and they can have any value.

    Only if none of PORRSTF and PINRSTF are set, the other bits are relevant.

    Even then you need to read the manual carefully to understand the conditions of these bits. There might be more to do than a simple single-bit check.