# RTC: Alarm interrupt missed, VBAT low flag set

- **ID:** `embedded/rtc-alarm-missed-due-to-battery-loss`
- **Domain:** embedded
- **Category:** runtime_error
- **Error Code:** `RTC_ERR_ALARM_MISSED`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

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

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32L4 RTC driver v1.3.0 | active | — | — |
| HAL RTC v1.2.5 | active | — | — |

## Workarounds

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);`** (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);`
   ```
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'); }`** (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'); }`
   ```

## Dead Ends

- **** — If VBAT is low, the RTC registers will reset again after the next power loss, and the alarm will be missed repeatedly. (85% fail)
- **** — Disabling the flag only hides the symptom; the RTC data integrity is still compromised and alarms will fail silently. (90% fail)
