I'm using the LPC4357 and sometimes it restarts (very rarely). I also use the RTC and after this reset, the RTC is initialized to default values. I perform initialization when oscillator that provides 32kHz for RTC, is not enabled. It is set in CREGO register. It means that I initialize RTC when CREG0 is reset and it also means that this MCU reset performs the CREG reset at the same time. According to the documentation:
there is only one type of reset that for sure reset CREG0 and there are some resets that perform "partial" reset of the CREG. There is no information in the documentation, what "partial" exactly means. I suspected the BOD reset but the ENABLE register is 0. So it is disabled.
Are there any other causes that can perform MCU reset and reset the CREG at the same time?
What can cause the Power on Reset during work which can reset my CREG?
This problem is caused by POR reset.
BOD doesn't reset CREG but POR does.
You can solve the problem with below code.
&= ~((1 << 3) | (1 << 2)); /* Reset 32Khz oscillator */
|= (1 << 1) | (1 << 0); /* Enable 32 kHz & 1 kHz on
Hope this helps,
That's what I have exactly in my code when I do the RTC initialization. I do not make initialization every single time when the device is power up. Firstly I check whether the RESET32KHZ and PD32KHZ bits in CREG0 are set. If they are set to 1, it means the CREG0 has been restarted and then I do RTC init. But it's not what I'm asking for.
The problem is that my code sometimes restarts. The RTC reinitialization is just a trace that this emerging reset performs a CREG0 reset. So I can eliminate other types of resets. I'm trying to find out what can cause the CREG0 reset.
If only the Power on Reset can cause the CREG0 reset, I would like to ask you what can be the reasons of the Power on Reset? What can causes the PoR?
POR doesn’t occur when Vbat = ON and VCC = OFF. It only occurs during power on (VCC from 0 to VDD).
Here is some Q&A you may also concern:
1. If Vbat = ON and VCC = OFF, does 32KHz stop?
2. If Vbat = ON and VCC = OFF, does RTC stop?
to avoid POR reset CREG0, the only way is to use deep power down mode rather than power off the board. deep power down mode won't reset CREG0.
Hope this helps,