embedded runtime_error ai_generated true

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

RTC: alarm interrupt not triggering at configured time

ID: embedded/rtc-alarm-interrupt-not-triggering

其他格式: JSON · Markdown 中文 · English
85%修复率
85%置信度
1证据数
2024-02-15首次发现

版本兼容性

版本状态引入弃用备注
STM32Cube_FW_H7 V1.11.0 active
FreeRTOS V10.4.1 active

根因分析

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

English

RTC alarm interrupt failed to fire due to incorrect mask configuration or pending interrupt flag not cleared.

generic

官方文档

https://www.st.com/resource/en/reference_manual/dm00314099.pdf

解决方案

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

无效尝试

常见但无效的做法:

  1. 90% 失败

    Increasing RTC clock prescaler changes alarm timing but does not fix interrupt configuration.

  2. 80% 失败

    Reinitializing RTC peripheral resets all registers, losing alarm settings.

  3. 70% 失败

    Adding delay loops after alarm set does not address missing interrupt enable.