STM32N655X0 RTC Stops Counting After Power-Off Depending on the Previous Boot Mode or Firmware Flashing Method
Hi everyone,
We are facing an issue with the RTC on our custom hardware based on the STM32N655X0 MCU and would appreciate any suggestions to help us identify the root cause.
1. Project Overview
We have configured the RTC in our application, and maintaining the correct time across power cycles is an important project requirement.
Our firmware is stored in external flash. During development, we use J-Link for programming, and we have also implemented firmware flashing through USB using an FSBL with DFU support.
Both flashing methods work successfully. However, we have observed unexpected RTC behaviour after flashing and subsequent power cycles.
2. Issue Description
After flashing the firmware, if we remove the main supply (VDD) and power the board back on after a few minutes, the RTC does not account for the elapsed time correctly.
For example, if flashing completes at 12:25 PM and we power off the board immediately, then power it back on at 12:30 PM, the RTC does not reflect the five-minute interval as expected.
We initially suspected the external loader because it is common to both programming methods. To investigate this, we tried enabling the LSE in the external loader and initializing the RTC in the FSBL. However, the issue persisted.
3. Experiments and Observations
Experiment 1: Flashing through J-Link
- We configure the boot pins for development mode.
- We flash the firmware successfully using J-Link.
- After removing VDD and powering the board back on, the RTC does not reflect the elapsed power-off time.
Experiment 2: Flashing through USB
- We configure the boot pins for serial boot mode or use the FSBL with DFU support.
- We flash the firmware to external flash successfully.
- After removing VDD and powering the board back on, the RTC again fails to account for the elapsed time.
Experiment 3: Power cycling without flashing
We also tested the behaviour without performing any firmware flashing:
- We configure the boot pins for development mode, power on the board, and then power it off without performing any programming operation.
- After waiting five minutes, we power the board back on and observe that the RTC has not advanced by the expected five minutes.
- However, when the board's previous boot mode is flash mode, the RTC correctly reflects the elapsed five-minute interval after power-off.
This suggests that the RTC behaviour is related to the board's previous boot mode or the state established during the preceding power cycle, rather than being caused exclusively by the firmware flashing operation.
Experiment 4: Power cycling without removing VDD
When we perform an immediate power cycle after flashing without removing the main VDD supply, we observe an approximately 30-second discrepancy in the RTC time.
4. Backup Domain and VBAT
- VBAT is supplied to the MCU.
- We have verified that the backup registers are not being cleared.
- We use a backup register with a known value to determine whether RTC initialization is required. If the expected value is absent, the application initializes the RTC with a default time.
- During these tests, the RTC does not revert to the default time, and the known backup-register value remains present.
Therefore, the observed issue does not appear to be caused by the backup registers being cleared.
Since RTC timekeeping across power cycles is a critical requirement for our project, any suggestions or pointers would be greatly appreciated.
Thank you!
