When testing a arch_max based project, I run into some mysterious problem. The app will sync RTC time to a remote NTP server every 6 hours. Occasionally system will crash and output “HAL_RTC_SetDate error” into console. Similar app running on STM32F401RE with ESP8266 doesn’t have such problem.
Can anybody provide some pointers on how to debug?
For anyone who is interested or runs into similar problem, the issue is hunted down to:
HAL_PWR_DisableBkUpAccess();
This line of code is called after saving some variables into RTC backup registers. When this line executes, it messes up HAL_RTC_SetDate() which is called by set_time();
I was under the impression that this line only disables access to RTC backup registers and backup SRAM, but according to user manual, despite its name, it also disables access to RTC registers. Its counter part is called during RTC initialization.