stm32 rtc 读取数据不正常

需求 stm32 使用 hal 读取 rtc 数据时,发现数据读取要不是 0,要不就不变,比较奇怪。 解决 经过多次调试并查看源码,才发现,API的注释里面写了,需要先调用 HAL_RTC_GetTime, 再调用 HAL_RTC_GetDate, 才行,否则就不行。因为先读取 time 可以解锁读取。 =You must call HAL_RTC_GetDate() after HAL_RTC_GetTime() to unlock the values in the higher-order calendar shadow registers to ensure consistency between the time and date values.= 参考

2023-12-12 · 1 min · 42 words · RamLife