# RTC：校准调整失败，RTC_ISR_INITF在2秒内未置位

- **ID:** `embedded/rtc-calibration-trim-failed`
- **领域:** embedded
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 91%

## 根因

设置INIT位后RTC初始化标志(INITF)未置位，可能是由于校准模式进入期间备份域写保护持续激活或时钟源不稳定。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| STM32Cube_FW_H7 v1.9.0 | active | — | — |
| ARM GCC v11.3.1 | active | — | — |
| HAL RTC driver v2.6.0 | active | — | — |

## 解决方案

1. ```
   在RTC校准前确保备份域访问已启用：调用HAL_PWR_EnableBkUpAccess()并等待PWR_CR1_DBP位置位。然后在设置INIT位后通过向RTC_ISR写入0来清除RTC_ISR_INITF。
   ```
2. ```
   如果外部晶振不稳定，使用LSE时钟旁路：配置RCC_LSEConfig(RCC_LSE_ON)并启用旁路模式，在进入校准模式前验证LSERDY标志。
   ```

## 无效尝试

- **Increase timeout for INITF flag to 10 seconds** — Longer timeout does not fix the root cause; flag will never set if backup domain is locked or clock is missing. (95% 失败率)
- **Reset entire RTC peripheral by toggling RTCEN bit in RCC_BDCR** — Toggling RTCEN resets all RTC registers, losing time and date; calibration failure persists if write protection issue is not resolved. (80% 失败率)
