# RTC：闹钟中断未在配置时间触发

- **ID:** `embedded/rtc-alarm-interrupt-not-triggering`
- **领域:** embedded
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

RTC 闹钟中断因掩码配置错误或未清除挂起中断标志而未触发。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32Cube_FW_H7 V1.11.0 | active | — | — |
| FreeRTOS V10.4.1 | active | — | — |

## 解决方案

1. ```
   在设置闹钟前检查并清除 RTC_ISR 中的 RTC_ISR_ALRAF 标志，然后在 RTC_CR 中使能闹钟中断：`RTC->CR |= RTC_CR_ALRAIE;`
   ```
2. ```
   确保 RTC_CR 中的闹钟掩码位（ALRAE、ALRABIN）正确配置为所需闹钟模式。
   ```
3. ```
   使用 HAL_RTC_AlarmIRQHandler() 函数，它会自动清除挂起标志并重新使能中断。
   ```

## 无效尝试

- **** — Increasing RTC clock prescaler changes alarm timing but does not fix interrupt configuration. (90% 失败率)
- **** — Reinitializing RTC peripheral resets all registers, losing alarm settings. (80% 失败率)
- **** — Adding delay loops after alarm set does not address missing interrupt enable. (70% 失败率)
