HAL TAMP How to Use

group TAMP_How_To_Use

The antitamper detection circuit is used to protect sensitive data from external attacks. The detection is made on an event of the different tamper I/O or on internal monitors detecting out-of-range device conditions.

The TAMP driver provides:

  • external tampers that can work in two modes:

    • active mode that is a continuous comparison between a tamper output and input

    • passive mode that are ultra-low power edge or level detection

  • internal tampers to protect against transient or environmental perturbation of the microcontroller

  • monotonic counters

  • backup registers read/write

  • configuration of device secret protection

TAMP operating condition

The antitamper detection circuit is part of the backup domain and can be powered from VBAT when the main VDD supply is powered off. When VDD is turned off, it is possible to retain the content of the TAMP registers and supply the TAMP peripheral. To do so, the VBAT can be connected to an optional standby voltage supplied by a battery or by another source.

The TAMP clock also used by the RTC driver, is called RTCCLK and can come from different sources:

  • HSE

  • LSE

  • LSI

Backup domain reset

The backup domain reset sets all TAMP registers and the RCC_BDCR register to their reset values. A backup domain reset occurs when:

  • triggered by setting the BDRST bit in the RCC backup domain control register (RCC_BDCR).

  • totally powering off the microcontroller.

Backup domain access

After reset, the backup domains are protected against possible unwanted write accesses. To enable access to the TAMP domain and TAMP registers, proceed as follows:

  • Enable the clock driving the power controller interface using the HAL_RCC_PWR_EnableClock function

  • Enable access to backup domain using the HAL_PWR_DisableBackupDomainWriteProtection function

  • Select the RTC clock source using the HAL_RCC_RTC_SetKernelClkSource function

  • Enable RTCAPB clock using the HAL_RCC_RTCAPB_EnableClock function

TAMP and microcontroller low power modes

The MCU can be woken up from low power mode by a tamper event.