RTC_ERR_ALARM_MISSED embedded runtime_error ai_generated true

RTC: Alarm interrupt missed, VBAT low flag set

ID: embedded/rtc-alarm-missed-due-to-battery-loss

Also available as: JSON · Markdown · 中文
90%Fix Rate
82%Confidence
1Evidence
2023-11-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
STM32L4 RTC driver v1.3.0 active
HAL RTC v1.2.5 active

Root Cause

The backup battery (VBAT) voltage dropped below the threshold, causing the RTC registers to reset and the alarm to be missed.

generic

中文

备份电池电压降至阈值以下,导致RTC寄存器复位,闹钟丢失。

Official Documentation

https://www.st.com/resource/en/application_note/an4759-rtc-usage-with-stm32l4-series-stmicroelectronics.pdf

Workarounds

  1. 95% success Replace the backup battery and reinitialize the RTC with the correct time and alarm: `rtc_init(); rtc_set_time(&correct_time); rtc_set_alarm(&alarm_time);`
    Replace the backup battery and reinitialize the RTC with the correct time and alarm: `rtc_init(); rtc_set_time(&correct_time); rtc_set_alarm(&alarm_time);`
  2. 80% success Add a VBAT monitoring routine to warn the user before the battery is critically low: `if (rtc_check_vbat_low()) { log_warning('VBAT low, replace battery'); }`
    Add a VBAT monitoring routine to warn the user before the battery is critically low: `if (rtc_check_vbat_low()) { log_warning('VBAT low, replace battery'); }`

中文步骤

  1. Replace the backup battery and reinitialize the RTC with the correct time and alarm: `rtc_init(); rtc_set_time(&correct_time); rtc_set_alarm(&alarm_time);`
  2. Add a VBAT monitoring routine to warn the user before the battery is critically low: `if (rtc_check_vbat_low()) { log_warning('VBAT low, replace battery'); }`

Dead Ends

Common approaches that don't work:

  1. 85% fail

    If VBAT is low, the RTC registers will reset again after the next power loss, and the alarm will be missed repeatedly.

  2. 90% fail

    Disabling the flag only hides the symptom; the RTC data integrity is still compromised and alarms will fail silently.