36. Tamper and backup registers (TAMP) applied to STM32L41xxx and STM32L42xxx devices only

36.1 Introduction

32 32-bit backup registers are retained in all low-power modes and also in \( V_{BAT} \) mode. They can be used to store sensitive data as their content is protected by an tamper detection circuit. 2 tamper pins are available for anti-tamper detection. The external tamper pins can be configured for edge detection, or level detection with or without filtering.

36.2 TAMP main features

36.3 TAMP functional description

36.3.1 TAMP block diagram

Figure 357. TAMP block diagram

TAMP block diagram showing internal components like Tamper detection (EDGE and LEVEL), an OR gate for flags (TAMP1F, TAMP2F, TAMPxF), Backup registers, and interfaces (IRQ, Registers) connected to pins like TAMP_IN1, TAMP_IN2, TAMP_INx, tamp_ker_ck, tamp_evt, tamp_it, and tamp_pclk.

The diagram illustrates the internal architecture of the TAMP block. On the left, external pins are shown: TAMP_IN1, TAMP_IN2, an ellipsis, TAMP_INx, tamp_ker_ck, tamp_evt, tamp_it, and tamp_pclk. The TAMP_IN pins connect to individual 'Tamper detection' blocks. Each block contains 'EDGE detection' and 'LEVEL detection' sub-blocks. These sub-blocks output flags: TAMP1F, TAMP2F, and TAMPxF (1) . These flags are inputs to a large OR gate. The output of the OR gate is connected to the 'Backup registers' block and also to the tamp_trg1 and tamp_trg2 pins. The tamp_ker_ck pin provides a clock signal to the 'Backup registers' block, which is labeled as the 'tamp_ker_ck clock domain'. The tamp_pclk pin provides a clock signal to the 'IRQ interface' and 'Registers interface' blocks, which are labeled as the 'tamp_pclk clock domain'. The 'Backup registers' block is also connected to the 'IRQ interface' and 'Registers interface' blocks. The 'IRQ interface' and 'Registers interface' blocks are connected to the tamp_it and tamp_pclk pins. The tamp_evt pin is an output from the 'Backup registers' block. The diagram is labeled with MSv43847V2 at the bottom right.

TAMP block diagram showing internal components like Tamper detection (EDGE and LEVEL), an OR gate for flags (TAMP1F, TAMP2F, TAMPxF), Backup registers, and interfaces (IRQ, Registers) connected to pins like TAMP_IN1, TAMP_IN2, TAMP_INx, tamp_ker_ck, tamp_evt, tamp_it, and tamp_pclk.

1. The number of external tampers depends on products.

36.3.2 TAMP pins and internal signals

Table 183. TAMP input/output pins

Pin nameSignal typeDescription
TAMP_INx (x = pin index)InputTamper input pin

Table 184. TAMP internal input/output signals

Internal signal nameSignal typeDescription
tamp_ker_ckInputTAMP kernel clock, connected to rtc_ker_ck and also named RTCCLK in this document
tamp_pclkInputTAMP APB clock, connected to rtc_pclk
tamp_evtOutputTamper event detection (internal or external)
The tamp_evt is used to generate a RTC timestamp event
tamp_eraseOutputDevice secrets erase request following either tamper event detection (internal or external) or the software erase request done by writing BKERASE to 1
tamp_itOutputTAMP interrupt (refer to Section 36.5: TAMP interrupts for details)
tamp_trg[x]
(x = signal index)
OutputTamper detection trigger

The TAMP kernel clock is usually the LSE at 32.768 kHz although it is possible to select other clock sources in the RCC (refer to RCC for more details). Some detections modes are not available in some low-power modes or \( V_{BAT} \) when the selected clock is not LSE (refer to Section 36.4: TAMP low-power modes for more details).

Table 185. TAMP interconnection

Signal nameSource/Destination
tamp_evtrtc_tamp_evt used to generate a timestamp event
tamp_eraseThe tamp_erase signal is used to erase the device secrets listed hereafter: backup registers

36.3.3 TAMP register write protection

After system reset, the TAMP registers (including backup registers) are protected against parasitic write access by the DBP bit in the power control peripheral (refer to the PWR power control section). DBP bit must be set in order to enable TAMP registers write access.

36.3.4 Tamper detection

The tamper detection can be configured for the following purposes:

TAMP backup registers

The backup registers (TAMP_BKPxR) are not reset by system reset or when the device wakes up from Standby mode.

The backup registers are reset when a tamper detection event occurs except if the TAMPxNOER bit is set, or if the TAMPxMSK is set in the TAMP_CR2 register.

The backup registers can be reset by software by setting the BKERASE bit in the TAMP_CR2 register.

Note: The backup registers are also erased when the readout protection of the flash is changed from level 1 to level 0.

Tamper detection initialization

Each input can be enabled by setting the corresponding TAMPxE bits to 1 in the TAMP_CR register.

Each TAMP_INx tamper detection input is associated with a flag TAMPxF in the TAMP_SR register.

When TAMPxMSK is cleared:

The TAMPxF flag is asserted after the tamper event on the pin, with the latency provided below:

A new tamper occurring on the same pin during this period and as long as TAMPxF is set cannot be detected.

When TAMPxMSK is set:

A new tamper occurring on the same pin cannot be detected during the latency described above and 2.5 ck_rtc additional cycles.

By setting the TAMPxIE bit in the TAMP_IER register, an interrupt is generated when a tamper detection event occurs (when TAMPxF is set). Setting TAMPxIE is not allowed when the corresponding TAMPxMSK is set.

Trigger output generation on tamper event

The tamper event detection can be used as trigger input by the low-power timers.

When TAMPxMSK bit is cleared in TAMP_CR register, the TAMPxF flag must be cleared by software in order to allow a new tamper detection on the same pin.

When TAMPxMSK bit is set, the TAMPxF flag is masked, and kept cleared in TAMP_SR register. This configuration allows the low-power timers in Stop mode to be triggered automatically, without requiring the system wake-up to perform the TAMPxF clearing. In this case, the backup registers are not cleared.

This feature is available only when the tamper is configured in the Level detection with filtering on tamper inputs (passive mode) mode.

Timestamp on tamper event

With TAMPTS set to 1 in the RTC_CR, any tamper event causes a timestamp to occur. In this case, either the TSF bit or the TSOVF bit is set in RTC_SR, in the same manner as if a normal timestamp event occurs. The affected tamper flag register TAMPxF is set in the TAMP_SR at the same time that TSF or TSOVF is set in the RTC_SR.

Edge detection on tamper inputs (passive mode)

If the TAMPFLT bits are 00, the TAMP_INx pins generate tamper detection events when either a rising edge/high level or a falling edge/low level is observed depending on the corresponding TAMPxTRG bit. The internal pull-up resistors on the TAMP_INx inputs are deactivated when edge detection is selected.

Caution: When using the edge detection, it is recommended to check by software the tamper pin level just after enabling the tamper detection (by reading the GPIO registers), and before writing sensitive values in the backup registers, to ensure that an active edge did not occur before enabling the tamper event detection.
When TAMPFLT = 00 and TAMPxTRG = 0 (rising edge detection), a tamper event may be detected by hardware if the tamper input is already at high level before enabling the tamper detection.

After a tamper event has been detected and cleared, the TAMP_INx should be disabled and then re-enabled (TAMPxE set to 1) before re-programming the backup registers (TAMP_BKPxR). This prevents the application from writing to the backup registers while the TAMP_INx input value still indicates a tamper detection. This is equivalent to a level detection on the TAMP_INx input.

Note: Tamper detection is still active when \( V_{DD} \) power is switched off. To avoid unwanted resetting of the backup registers, the pin to which the TAMPx is mapped should be externally tied to the correct level.

Level detection with filtering on tamper inputs (passive mode)

Level detection with filtering is performed by setting TAMPFLT to a non-zero value. A tamper detection event is generated when either 2, 4, or 8 (depending on TAMPFLT) consecutive samples are observed at the level designated by the TAMPxTRG bits.

The TAMP_INx inputs are precharged through the I/O internal pull-up resistance before its state is sampled, unless disabled by setting TAMPPUDIS to 1. The duration of the precharge is determined by the TAMPPRCH bits, allowing for larger capacitances on the TAMP_INx inputs.

The trade-off between tamper detection latency and power consumption through the pull-up can be optimized by using TAMPFREQ to determine the frequency of the sampling for level detection.

Note: Refer to the microcontroller datasheet for the electrical characteristics of the pull-up resistors.

36.4 TAMP low-power modes

Table 186. Effect of low-power modes on TAMP

ModeDescription
SleepNo effect.
TAMP interrupts cause the device to exit the Sleep mode.
StopNo effect on all features, except for level detection with filtering mode which remain active only when the clock source is LSE or LSI.
Tamper events cause the device to exit the Stop mode.
StandbyNo effect on all features, except for level detection with filtering mode which remain active only when the clock source is LSE or LSI. Tamper events cause the device to exit the Standby mode.
ShutdownNo effect on all features, except for level detection with filtering mode which remain active only when the clock source is LSE. Tamper events cause the device to exit the Shutdown mode.

36.5 TAMP interrupts

The interrupt channel is set in the interrupt status register. The interrupt output is also activated.

Table 187. Interrupt requests

Interrupt acronymInterrupt eventEvent flag (1)Enable control bit (2)Interrupt clear methodExit from Sleep modeExit from Stop and Standby modesExit from Shutdown mode
TAMPTamper x (3)TAMPxFTAMPxEWrite 1 in CTAMPxFYesYes (4)Yes (5)
  1. 1. The event flags are in the TAMP_SR register.
  2. 2. The interrupt masked flags (resulting from event flags AND enable control bits) are in the TAMP_MISR register.
  3. 3. The number of tampers events depend on products.
  4. 4. In case of level detection with filtering passive tamper mode, wake-up from Stop and Standby modes is possible only when the TAMP clock source is LSE or LSI.
  5. 5. In case of level detection with filtering passive tamper mode, wake-up from Shutdown modes is possible only when the TAMP clock source is LSE.

36.6 TAMP registers

Refer to Section 1.2 on page 64 of the reference manual for a list of abbreviations used in register descriptions. The peripheral registers can be accessed by words (32-bit).

36.6.1 TAMP control register 1 (TAMP_CR1)

Address offset: 0x00

Backup domain reset value: 0xFFFF 0000

System reset: not affected

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP2
E
TAMP1
E
rwrw

Bits 31:24 Reserved, must be kept at reset value.

Bit 23 Reserved, must be kept at reset value.

Bit 22 Reserved, must be kept at reset value.

Bit 21 Reserved, must be kept at reset value.

Bit 20 Reserved, must be kept at reset value.

Bit 19 Reserved, must be kept at reset value.

Bit 18 Reserved, must be kept at reset value.

Bit 17 Reserved, must be kept at reset value.

Bit 16 Reserved, must be kept at reset value.

Bits 15:2 Reserved, must be kept at reset value.

Bit 1 TAMP2E : Tamper detection on TAMP_IN2 enable (1)

0: Tamper detection on TAMP_IN2 is disabled.

1: Tamper detection on TAMP_IN2 is enabled.

Bit 0 TAMP1E : Tamper detection on TAMP_IN1 enable (1)

0: Tamper detection on TAMP_IN1 is disabled.

1: Tamper detection on TAMP_IN1 is enabled.

36.6.2 TAMP control register 2 (TAMP_CR2)

Address offset: 0x04

Backup domain reset value: 0x0000 0000

System reset: not affected

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.TAMP2 TRGTAMP1 TRGBK ERASERes.Res.Res.Res.Res.TAMP2 MSKTAMP1 MSK
rwrwwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP2 NOERTAMP1 NOER
rwrw

Bits 31:26 Reserved, must be kept at reset value.

Bit 25 TAMP2TRG : Active level for tamper 2 input

Bit 24 TAMP1TRG : Active level for tamper 1 input

Bit 23 BKERASE : Backup registers erase

Writing '1' to this bit reset the backup registers. Writing 0 has no effect. This bit is always read as 0.

Bits 22:18 Reserved, must be kept at reset value.

Bit 17 TAMP2MSK : Tamper 2 mask

Bit 16 TAMP1MSK : Tamper 1 mask

Bits 15:2 Reserved, must be kept at reset value.

Bit 1 TAMP2NOER : Tamper 2 no erase

0: Tamper 2 event erases the backup registers.

1: Tamper 2 event does not erase the backup registers.

Bit 0 TAMP1NOER : Tamper 1 no erase

0: Tamper 1 event erases the backup registers.

1: Tamper 1 event does not erase the backup registers.

36.6.3 TAMP filter control register (TAMP_FLTCR)

Address offset: 0x0C

Backup domain reset value: 0x0000 0000

System reset: not affected

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.TAMP
PUDIS
TAMPPRCH
[1:0]
TAMPFLT
[1:0]
TAMPFREQ
[2:0]
rwrwrwrwrwrwrwrw

Bits 31:8 Reserved, must be kept at reset value.

Bit 7 TAMPPUDIS : TAMP_INx pull-up disable

This bit determines if each of the TAMPx pins are precharged before each sample.

0: Precharge TAMP_INx pins before sampling (enable internal pull-up)

1: Disable precharge of TAMP_INx pins.

Bits 6:5 TAMPPRCH[1:0] : TAMP_INx precharge duration

These bits determine the duration of time during which the pull-up is activated before each sample. TAMPPRCH is valid for each of the TAMP_INx inputs.

Bits 4:3 TAMPFLT[1:0] : TAMP_INx filter count

These bits determine the number of consecutive samples at the specified level (TAMP*TRG) needed to activate a tamper event. TAMPFLT is valid for each of the TAMP_INx inputs.

Bits 2:0 TAMPFREQ[2:0] : Tamper sampling frequency

Determines the frequency at which each of the TAMP_INx inputs are sampled.

Note: This register concerns only the tamper inputs in passive mode.

36.6.4 TAMP interrupt enable register (TAMP_IER)

Address offset: 0x2C

Backup domain reset value: 0x0000 0000

System reset: not affected

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP
2IE
TAMP
1IE
rwrw

Bits 31:24 Reserved, must be kept at reset value.

Bit 23 Reserved, must be kept at reset value.

Bit 22 Reserved, must be kept at reset value.

Bit 21 Reserved, must be kept at reset value.

Bit 20 Reserved, must be kept at reset value.

36.6.5 TAMP status register (TAMP_SR)

Address offset: 0x30

Backup domain reset value: 0x0000 0000

System reset: not affected

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP
2F
TAMP
1F
rr

36.6.6 TAMP masked interrupt status register (TAMP_MISR)

Address offset: 0x34

Backup domain reset value: 0x0000 0000

System reset: not affected

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP
2MF
TAMP
1MF
rr

Bits 31:24 Reserved, must be kept at reset value.

Bit 23 Reserved, must be kept at reset value.

Bit 22 Reserved, must be kept at reset value.

Bit 21 Reserved, must be kept at reset value.

Bit 20 Reserved, must be kept at reset value.

Bit 19 Reserved, must be kept at reset value.

Bit 18 Reserved, must be kept at reset value.

Bit 17 Reserved, must be kept at reset value.

Bit 16 Reserved, must be kept at reset value.

Bits 15:2 Reserved, must be kept at reset value.

Bit 1 TAMP2MF : TAMP2 interrupt masked flag

This flag is set by hardware when the tamper 2 interrupt is raised.

Bit 0 TAMP1MF : TAMP1 interrupt masked flag

This flag is set by hardware when the tamper 1 interrupt is raised.

36.6.7 TAMP status clear register (TAMP_SCR)

Address offset: 0x3C

System reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CTAMP
2F
CTAMP
1F
ww

36.6.8 TAMP backup x register (TAMP_BKPxR)

Address offset: 0x100 + 0x04 * x, (x = 0 to 31)

Backup domain reset value: 0x0000 0000

System reset: not affected

31302928272625242322212019181716
BKP[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
BKP[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwwrwrw

Bits 31:0 BKP[31:0]:

The application can write or read data to and from these registers.

They are powered-on by V BAT when V DD is switched off, so that they are not reset by System reset, and their contents remain valid when the device operates in low-power mode.

In the default configuration this register is reset on a tamper detection event. It is forced to reset value as long as there is at least one external tamper flag being set. This register is also reset when the readout protection (RDP) is disabled.

36.6.9 TAMP register map

Table 188. TAMP register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00TAMP_CR1Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP2ETAMP1E
Reset value00
0x04TAMP_CR2Res.Res.Res.Res.Res.Res.TAMP2TRGTAMP1TRGBKERASERes.Res.Res.Res.Res.TAMP2MSKTAMP1MSKRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP2NOERTAMP1NOER
Reset value0000000
0x0CTAMP_FLTCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMPPLUDISTAMP2PRCH[1:0]TAMPFLT[1:0]TAMPFREQ[2:0]
Reset value00000000
0x2CTAMP_IERRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP2IETAMP1IE
Reset value00
0x30TAMP_SRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP2FTAMP1F
Reset value00
0x34TAMP_MISRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TAMP2MFTAMP1MF
Reset value00
0x3CTAMP_SCRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.CTAMP2FCTAMP1F
Reset value00
0x100 +
0x04*x,
(x=
0 to 31)
TAMP_BKPxRBKP[31:0]
Reset value00000000000000000000000000000000

Refer to Section 2.2 for the register boundary addresses.