# RTC: calibration trim failed, RTC_ISR_INITF not set within 2 seconds

- **ID:** `embedded/rtc-calibration-trim-failed`
- **Domain:** embedded
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 91%

## Root Cause

RTC initialization flag (INITF) did not assert after setting INIT bit, likely due to ongoing backup domain write protection or clock source instability during calibration mode entry.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32Cube_FW_H7 v1.9.0 | active | — | — |
| ARM GCC v11.3.1 | active | — | — |
| HAL RTC driver v2.6.0 | active | — | — |

## Workarounds

1. **Ensure backup domain access is enabled before RTC calibration: call HAL_PWR_EnableBkUpAccess() and wait for PWR_CR1_DBP bit to be set. Then clear RTC_ISR_INITF by writing 0 to RTC_ISR after setting INIT bit.** (94% success)
   ```
   Ensure backup domain access is enabled before RTC calibration: call HAL_PWR_EnableBkUpAccess() and wait for PWR_CR1_DBP bit to be set. Then clear RTC_ISR_INITF by writing 0 to RTC_ISR after setting INIT bit.
   ```
2. **Use LSE clock bypass if external crystal is unstable: configure RCC_LSEConfig(RCC_LSE_ON) with bypass mode and verify LSERDY flag before entering calibration mode.** (87% success)
   ```
   Use LSE clock bypass if external crystal is unstable: configure RCC_LSEConfig(RCC_LSE_ON) with bypass mode and verify LSERDY flag before entering calibration mode.
   ```

## Dead Ends

- **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% fail)
- **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% fail)
