# RTC: Tamper detection triggered on pin TAMP1, system halted

- **ID:** `embedded/rtc-tamper-detection-triggered`
- **Domain:** embedded
- **Category:** system_error
- **Error Code:** `RTC_TAMP_FLAG`
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

RTC tamper pin (TAMP1) detected an external event, causing a hardware-level system halt to protect sensitive data.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| STM32CubeFW_L4 v1.18.0 | active | — | — |
| HAL_RTC v2.0.3 | active | — | — |
| ARM Cortex-M4 r0p1 | active | — | — |

## Workarounds

1. **Disable the tamper pin in the RTC configuration after detecting the event: HAL_RTCEx_DeactivateTamper(&hrtc, RTC_TAMPER_1);** (85% success)
   ```
   Disable the tamper pin in the RTC configuration after detecting the event: HAL_RTCEx_DeactivateTamper(&hrtc, RTC_TAMPER_1);
   ```
2. **Implement a debounce mechanism in firmware to filter out spurious tamper events: if (HAL_GPIO_ReadPin(TAMP1_GPIO_Port, TAMP1_Pin) == GPIO_PIN_RESET) { HAL_RTCEx_DeactivateTamper(&hrtc, RTC_TAMPER_1); }** (75% success)
   ```
   Implement a debounce mechanism in firmware to filter out spurious tamper events: if (HAL_GPIO_ReadPin(TAMP1_GPIO_Port, TAMP1_Pin) == GPIO_PIN_RESET) { HAL_RTCEx_DeactivateTamper(&hrtc, RTC_TAMPER_1); }
   ```

## Dead Ends

- **** — The tamper detection is edge-triggered; clearing the flag without reconfiguring the pin leaves the system in an unstable loop. (90% fail)
- **** — Tamper detection is independent of the backup domain reset; it only depends on the TAMP pin configuration. (70% fail)
