14. Extended interrupts and events controller (EXTI)

14.1 Introduction

The EXTI main features are as follows:

14.2 EXTI main features

The extended interrupts and events controller (EXTI) manages the external and internal asynchronous events/interrupts and generates the event request to the CPU/Interrupt Controller and a wake-up request to the Power Controller.

The EXTI allows the management of up to 40 (STM32L47x/L48x devices), up to 41 (STM32L49x/L4Ax devices) event lines which can wake up from the Stop 0 and Stop 1 modes. Not all events can wake up from the Stop 2 mode (refer to Table 59: EXTI lines connections ).

The lines are either configurable or direct:

Each line can be masked independently for an interrupt or an event generation.

This controller also allows to emulate events or interrupts by software, multiplexed with the corresponding hardware event line, by writing to a dedicated register.

14.3 EXTI functional description

For the configurable interrupt lines, the interrupt line should be configured and enabled in order to generate an interrupt. This is done by programming the two trigger registers with the desired edge detection and by enabling the interrupt request by writing a '1' to the corresponding bit in the interrupt mask register. When the selected edge occurs on the interrupt line, an interrupt request is generated. The pending bit corresponding to the interrupt line is also set. This request is cleared by writing a '1' in the pending register.

For the direct interrupt lines, the interrupt is enabled by default in the interrupt mask register and there is no corresponding pending bit in the pending register.

To generate an event, the event line should be configured and enabled. This is done by programming the two trigger registers with the desired edge detection and by enabling the event request by writing a '1' to the corresponding bit in the event mask register. When the selected edge occurs on the event line, an event pulse is generated. The pending bit corresponding to the event line is not set.

For the configurable lines, an interrupt/event request can also be generated by software by writing a '1' in the software interrupt/event register.

Note: The interrupts or events associated to the direct lines are triggered only when the system is in Stop mode. If the system is still running, no interrupt/event is generated by the EXTI.

14.3.1 EXTI block diagram

The extended interrupt/event block diagram is shown on Figure 33.

Figure 33. Configurable interrupt/event block diagram

Figure 33. Configurable interrupt/event block diagram. The diagram shows the internal architecture of the EXTI block. At the top, an APB bus connects to a Peripheral interface, which is also connected to PCLK. Below the interface are six registers: Falling trigger selection register, Rising trigger selection register, Software interrupt event register, Event mask register, Interrupt mask register, and Pending request register. These registers are connected to a logic network. Configurable events enter an Edge detect circuit. Direct events pass through a Stop mode AND gate and then a Rising edge detect circuit. The outputs of the Edge detect circuit and the Rising edge detect circuit are combined with signals from the registers through a series of AND and OR gates to produce Interrupts, Events, and Wakeup signals. The identifier MS33393V1 is in the bottom right corner.
Figure 33. Configurable interrupt/event block diagram. The diagram shows the internal architecture of the EXTI block. At the top, an APB bus connects to a Peripheral interface, which is also connected to PCLK. Below the interface are six registers: Falling trigger selection register, Rising trigger selection register, Software interrupt event register, Event mask register, Interrupt mask register, and Pending request register. These registers are connected to a logic network. Configurable events enter an Edge detect circuit. Direct events pass through a Stop mode AND gate and then a Rising edge detect circuit. The outputs of the Edge detect circuit and the Rising edge detect circuit are combined with signals from the registers through a series of AND and OR gates to produce Interrupts, Events, and Wakeup signals. The identifier MS33393V1 is in the bottom right corner.

14.3.2 Wakeup event management

The STM32L47x/L48x/L49x/L4Ax is able to handle external or internal events in order to wake up the core (WFE). The wakeup event can be generated either by:

14.3.3 Peripherals asynchronous Interrupts

Some peripherals are able to generate events when the system is in run mode and also when the system is in Stop mode, allowing to wake up the system from Stop mode.

To accomplish this, the peripheral generates both a synchronized (to the system clock, e.g. APB clock) and an asynchronous version of the event. This asynchronous event is connected to an EXTI direct line.

Note: Few peripherals with wakeup from Stop capability are connected to an EXTI configurable line. In this case, the EXTI configuration is necessary to allow the wakeup from Stop mode.

14.3.4 Hardware interrupt selection

To configure a line as an interrupt source, use the following procedure:

  1. 1. Configure the corresponding mask bit in the EXTI_IMR register.
  2. 2. Configure the Trigger Selection bits of the Interrupt line (EXTI_RTSR and EXTI_FTSR).
  3. 3. Configure the enable and mask bits that control the NVIC IRQ channel mapped to the EXTI so that an interrupt coming from one of the EXTI lines can be correctly acknowledged.

Note: The direct lines do not require any EXTI configuration.

14.3.5 Hardware event selection

To configure a line as an event source, use the following procedure:

  1. 1. Configure the corresponding mask bit in the EXTI_EMR register.
  2. 2. Configure the Trigger Selection bits of the Event line (EXTI_RTSR and EXTI_FTSR).

14.3.6 Software interrupt/event selection

Any of the configurable lines can be configured as a software interrupt/event line. The procedure to generate a software interrupt is as follows:

  1. 1. Configure the corresponding mask bit (EXTI_IMR, EXTI_EMR).
  2. 2. Set the required bit of the software interrupt register (EXTI_SWIER).

14.4 EXTI interrupt/event line mapping

In the STM32L47x/L48x/L49x/L4Ax, 40 (STM32L47x/L48x devices), up to 41 (STM32L49x/L4Ax devices) interrupt/event lines are available. The GPIOs are connected to 16 configurable interrupt/event lines (see Figure 34 ).

Figure 34. External interrupt/event GPIO mapping

Diagram showing the mapping of GPIO pins to EXTI lines. It illustrates three multiplexers: one for EXTI0 (bits 0-3 in SYSCFG_EXTICR1) mapping pins PA0 through PI0(1) to EXTI0; one for EXTI1 (bits 4-7 in SYSCFG_EXTICR1) mapping pins PA1 through PI1(1) to EXTI1; and one for EXTI15 (bits 12-15 in SYSCFG_EXTICR4) mapping pins PA15 through PH15(1) to EXTI15. Vertical ellipses indicate intermediate lines.

MS46947V1

Diagram showing the mapping of GPIO pins to EXTI lines. It illustrates three multiplexers: one for EXTI0 (bits 0-3 in SYSCFG_EXTICR1) mapping pins PA0 through PI0(1) to EXTI0; one for EXTI1 (bits 4-7 in SYSCFG_EXTICR1) mapping pins PA1 through PI1(1) to EXTI1; and one for EXTI15 (bits 12-15 in SYSCFG_EXTICR4) mapping pins PA15 through PH15(1) to EXTI15. Vertical ellipses indicate intermediate lines.

1. Only on STM32L49x/L4Ax devices

The EXTI lines are connected as shown in Table 59: EXTI lines connections .

Table 59. EXTI lines connections

EXTI lineLine source (1)Line type
0-15GPIOconfigurable
16PVDconfigurable
17OTG FS wakeup event (2)(3)
(OTG_FS_WKUP)
direct
18RTC alarmsconfigurable

Table 59. EXTI lines connections (continued)

EXTI lineLine source (1)Line type
19RTC tamper or timestamp or CSS_LSEconfigurable
20RTC wakeup timerconfigurable
21COMP1 outputconfigurable
22COMP2 outputconfigurable
23I2C1 wakeup (2)direct
24I2C2 wakeup (2)direct
25I2C3 wakeupdirect
26USART1 wakeup (2)direct
27USART2 wakeup (2)direct
28USART3 wakeup (2)direct
29UART4 wakeup (2)direct
30UART5 wakeup (2)direct
31LPUART1 wakeupdirect
32LPTIM1direct
33LPTIM2 (2)direct
34SWPMI1 wakeup (2)direct
35PVM1 wakeupconfigurable
36PVM2 wakeupconfigurable
37PVM3 wakeupconfigurable
38PVM4 wakeupconfigurable
39LCD wakeup (4)direct
40 (5)I2C4 wakeupdirect

1. All the lines can wake up from the Stop 0 and Stop 1 modes. All the lines, except the ones mentioned above, can wake up from the Stop 2 mode.

2. This line source cannot wake up from the Stop 2 mode.

3. Available only on STM32L4x5/L4x6 devices.

4. Available only on STM32L4x6 devices.

5. Only for STM32L49x/L4Ax devices

14.5 EXTI registers

Refer to Section 1.2 on page 69 for a list of abbreviations used in register descriptions.

The peripheral registers have to be accessed by words (32-bit).

14.5.1 Interrupt mask register 1 (EXTI_IMR1)

Address offset: 0x00

Reset value: 0xFF82 0000

31302928272625242322212019181716
IM31IM30IM29IM28IM27IM26IM25IM24IM23IM22IM21IM20IM19IM18IM17IM16
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
IM15IM14IM13IM12IM11IM10IM9IM8IM7IM6IM5IM4IM3IM2IM1IM0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 IMx : Interrupt Mask on line x (x = 31 to 0)

0: Interrupt request from Line x is masked

1: Interrupt request from Line x is not masked

Note: The reset value for the direct lines (line 17, lines from 23 to 34, line 39) is set to '1' in order to enable the interrupt by default.

14.5.2 Event mask register 1 (EXTI_EMR1)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
EM31EM30EM29EM28EM27EM26EM25EM24EM23EM22EM21EM20EM19EM18EM17EM16
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
EM15EM14EM13EM12EM11EM10EM9EM8EM7EM6EM5EM4EM3EM2EM1EM0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 EMx : Event mask on line x (x = 31 to 0)

0: Event request from line x is masked

1: Event request from line x is not masked

14.5.3 Rising trigger selection register 1 (EXTI_RTSR1)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.RT22RT21RT20RT19RT18Res.RT16
rwrwrwrwrwrw

1514131211109876543210
RT15RT14RT13RT12RT11RT10RT9RT8RT7RT6RT5RT4RT3RT2RT1RT0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 22:18 RTx : Rising trigger event configuration bit of line x (x = 22 to 18)

0: Rising trigger disabled (for Event and Interrupt) for input line

1: Rising trigger enabled (for Event and Interrupt) for input line

Bit 17 Reserved, must be kept at reset value.

Bits 16:0 RTx : Rising trigger event configuration bit of line x (x = 16 to 0)

0: Rising trigger disabled (for Event and Interrupt) for input line

1: Rising trigger enabled (for Event and Interrupt) for input line

Note: The configurable wakeup lines are edge-triggered. No glitch must be generated on these lines. If a rising edge on a configurable interrupt line occurs during a write operation in the EXTI_RTSR register, the pending bit is not set.

Rising and falling edge triggers can be set for the same interrupt line. In this case, both generate a trigger condition.

14.5.4 Falling trigger selection register 1 (EXTI_FTSR1)

Address offset: 0x0C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.FT22FT21FT20FT19FT18Res.FT16
rwrwrwrwrwrw

1514131211109876543210
FT15FT14FT13FT12FT11FT10FT9FT8FT7FT6FT5FT4FT3FT2FT1FT0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 22:18 FTx : Falling trigger event configuration bit of line x (x = 22 to 18)

0: Falling trigger disabled (for Event and Interrupt) for input line

1: Falling trigger enabled (for Event and Interrupt) for input line

Bit 17 Reserved, must be kept at reset value.

Bits 16:0 FTx : Falling trigger event configuration bit of line x (x = 16 to 0)

0: Falling trigger disabled (for Event and Interrupt) for input line

1: Falling trigger enabled (for Event and Interrupt) for input line

Note: The configurable wakeup lines are edge-triggered. No glitch must be generated on these lines. If a falling edge on a configurable interrupt line occurs during a write operation to the EXTI_FTSR register, the pending bit is not set. Rising and falling edge triggers can be set for the same interrupt line. In this case, both generate a trigger condition.

14.5.5 Software interrupt event register 1 (EXTI_SWIER1)

Address offset: 0x10

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SWI 22SWI 21SWI 20SWI 19SWI 18Res.SWI 16
rwrwrwrwrwrw

1514131211109876543210
SWI 15SWI 14SWI 13SWI 12SWI 11SWI 10SWI 9SWI 8SWI 7SWI 6SWI 5SWI 4SWI 3SWI 2SWI 1SWI 0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 22: 18 SWIx : Software interrupt on line x (x = 22 o 18)

If the interrupt is enabled on this line in the EXTI_IMR, writing a '1' to this bit when it is at '0' sets the corresponding pending bit in EXTI_PR resulting in an interrupt request generation.

This bit is cleared by clearing the corresponding bit in the EXTI_PR register (by writing a '1' into the bit).

Bit 17 Reserved, must be kept at reset value.

Bits 16:0 SWIx : Software interrupt on line x (x = 16 to 0)

If the interrupt is enabled on this line in the EXTI_IMR, writing a '1' to this bit when it is at '0' sets the corresponding pending bit in EXTI_PR resulting in an interrupt request generation.

This bit is cleared by clearing the corresponding bit of EXTI_PR (by writing a '1' into the bit).

14.5.6 Pending register 1 (EXTI_PR1)

Address offset: 0x14

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.PIF22PIF21PIF20PIF19PIF18Res.PIF16
rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1
1514131211109876543210
PIF15PIF14PIF13PIF12PIF11PIF10PIF9PIF8PIF7PIF6PIF5PIF4PIF3PIF2PIF1PIF0
rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1

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

Bits 22:18 PIFx : Pending interrupt flag on line x (x = 22 to 18)

0: No trigger request occurred

1: Selected trigger request occurred

This bit is set when the selected edge event arrives on the interrupt line. This bit is cleared by writing a '1' to the bit.

Bit 17 Reserved, must be kept at reset value.

Bits 16:0 PIFx : Pending interrupt flag on line x (x = 16 to 0)

0: No trigger request occurred

1: Selected trigger request occurred

This bit is set when the selected edge event arrives on the interrupt line. This bit is cleared by writing a '1' to the bit.

14.5.7 Interrupt mask register 2 (EXTI_IMR2)

Address offset: 0x20

Reset value:

0x0000 0087 for STM32L47x/L48x devices

0x0000 0187 for STM32L49x/L4Ax devices

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.IM40IM39IM38IM37IM36IM35IM34IM33IM32
rwrwrwrwrwrwrwrwrw

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

Bits 8:0 IMx : Interrupt mask on line x (x = 40 to 32)

0: Interrupt request from line x is masked

1: Interrupt request from line x is not masked

Note: The reset value for the direct lines (line 17, lines from 23 to 34, line 40) is set to '1' in order to enable the interrupt by default.

Note: IM40 only applicable for STM32L49x/L4Ax devices

14.5.8 Event mask register 2 (EXTI_EMR2)

Address offset: 0x24

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.EM40EM39EM38EM37EM36EM35EM34EM33EM32
rwrwrwrwrwrwrwrwrw

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

Bits 8:0 EMx : Event mask on line x (x = 40 to 32)

0: Event request from line x is masked

1: Event request from line x is not masked

Note: EM40 only applicable for STM32L49x/L4Ax devices

14.5.9 Rising trigger selection register 2 (EXTI_RTSR2)

Address offset: 0x28

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.RT38RT37RT36RT35Res.Res.Res.
rwrwrwrw

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

Bits 7:3 RTx : Rising trigger event configuration bit of line x (x = 35 to 38)

0: Rising trigger disabled (for Event and Interrupt) for input line

1: Rising trigger enabled (for Event and Interrupt) for input line

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

Note: The configurable wakeup lines are edge-triggered. No glitch must be generated on these lines. If a rising edge on a configurable interrupt line occurs during a write operation to the EXTI_RTSR register, the pending bit is not set.

Rising and falling edge triggers can be set for the same interrupt line. In this case, both generate a trigger condition.

14.5.10 Falling trigger selection register 2 (EXTI_FTSR2)

Address offset: 0x2C

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.FT38FT37FT36FT35Res.Res.Res.
rwrwrwrw

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

Bits 7:3 FTx : Falling trigger event configuration bit of line x (x = 35 to 38)

0: Falling trigger disabled (for Event and Interrupt) for input line

1: Falling trigger enabled (for Event and Interrupt) for input line

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

Note: The configurable wakeup lines are edge-triggered. No glitch must be generated on these lines. If a falling edge on a configurable interrupt line occurs during a write operation to the EXTI_FTSR register, the pending bit is not set.

Rising and falling edge triggers can be set for the same interrupt line. In this case, both generate a trigger condition.

14.5.11 Software interrupt event register 2 (EXTI_SWIER2)

Address offset: 0x30

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.SWI38SWI37SWI36SWI35Res.Res.Res.
rwrwrwrw

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

Bit 7 SWIx : Software interrupt on line x (x = 35 to 38)

If the interrupt is enabled on this line in EXTI_IMR, writing a '1' to this bit when it is at '0' sets the corresponding pending bit of EXTI_PR resulting in an interrupt request generation.

This bit is cleared by clearing the corresponding bit of EXTI_PR (by writing a '1' to the bit).

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

14.5.12 Pending register 2 (EXTI_PR2)

Address offset: 0x34

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.PIF38PIF37PIF36PIF35Res.Res.Res.
rc_w1rc_w1rc_w1rc_w1

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

Bit 7 PIFx : Pending interrupt flag on line x (x = 35 to 38)

0: No trigger request occurred

1: Selected trigger request occurred

This bit is set when the selected edge event arrives on the interrupt line. This bit is cleared by writing a '1' into the bit.

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

14.5.13 EXTI register map

Table 60 gives the EXTI register map and the reset values.

Table 60. Extended interrupt/event controller register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00EXTI_IMR1IM31IM30IM29IM28IM27IM26IM25IM24IM23IM22IM21IM20IM19IM18IM17IM16IM15IM14IM13IM12IM11IM10IM9IM8IM7IM6IM5IM4IM3IM2IM1IM0
Reset value111111111000001000000000000000000
0x04EXTI_EMR1EM31EM30EM29EM28EM27EM26EM25EM24EM23EM22EM21EM20EM19EM18EM17EM16EM15EM14EM13EM12EM11EM10EM9EM8EM7EM6EM5EM4EM3EM2EM1EM0
Reset value00000000000000000000000000000000
0x08EXTI_RTSR1ResResResResResResResResResRT22RT21RT20RT19RT18ResRT16RT15RT14RT13RT12RT11RT10RT9RT8RT7RT6RT5RT4RT3RT2RT1RT0
Reset value0000000000000000000000
0x0CEXTI_FTSR1ResResResResResResResResResFT22FT21FT20FT19FT18ResFT16FT15FT14FT13FT12FT11FT10FT9FT8FT7FT6FT5FT4FT3FT2FT1FT0
Reset value0000000000000000000000
0x10EXTI_SWIER1ResResResResResResResResResSWI22SWI21SWI20SWI19SWI18ResSWI16SWI15SWI14SWI13SWI12SWI11SWI10SWI9SWI8SWI7SWI6SWI5SWI4SWI3SWI2SWI1SWI0
Reset value0000000000000000000000
0x14EXTI_PR1ResResResResResResResResResPIF22PIF21PIF20PIF19PIF18ResPIF16PIF15PIF14PIF13PIF12PIF11PIF10PIF9PIF8PIF7PIF6PIF5PIF4PIF3PIF2PIF1PIF0
Reset value0000000000000000000000
0x20EXTI_IMR2ResResResResResResResResResResResResResResResResResResResResResResResIM40IM39IM38IM37IM36IM35IM34IM33IM32
Reset value110000111
0x24EXTI_EMR2ResResResResResResResResResResResResResResResResResResResResResResResEM40EM39EM38EM37EM36EM35EM34EM33EM32
Reset value000000000
0x28EXTI_RTSR2ResResResResResResResResResResResResResResResResResResResResResResResResResRT38RT37RT36RT35ResResRes
Reset value0000
0x2CEXTI_FTSR2ResResResResResResResResResResResResResResResResResResResResResResResResResFT38FT37FT36FT35ResResRes
Reset value0000
0x30EXTI_SWIER2ResResResResResResResResResResResResResResResResResResResResResResResResResSWI38SWI37SWI36SWI35ResResRes
Reset value0000
0x34EXTI_PR2ResResResResResResResResResResResResResResResResResResResResResResResResResPIF38PIF37PIF36PIF35ResResRes
Reset value0000

Refer to Section 2.2 on page 75 for the register boundary addresses.