13. Extended interrupts and events controller (EXTI)

13.1 Introduction

The EXTI main features are as follows:

13.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 38 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 52: 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.

13.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.

13.3.1 EXTI block diagram

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

Figure 28. Configurable interrupt/event block diagram

Figure 28. Configurable interrupt/event block diagram. The diagram shows the internal architecture of the EXTI. At the top, an APB bus is connected to a Peripheral interface. The Peripheral interface is connected to six registers: Falling trigger selection register, Rising trigger selection register, Software interrupt event register, Event mask register, Interrupt mask register, and Pending request register. The Falling and Rising trigger selection registers are connected to an Edge detect circuit. The Software interrupt event register is connected to an OR gate. The Event mask register is connected to an AND gate. The Interrupt mask register is connected to an AND gate. The Pending request register is connected to an OR gate. The Edge detect circuit is connected to Configurable events. The Stop mode input is connected to an AND gate. The Rising edge detect is connected to the AND gate. The AND gate is connected to the OR gate. The OR gate is connected to Interrupts. The AND gate is connected to Events. The OR gate is connected to Wakeup. The diagram is labeled MS33393V1.
Figure 28. Configurable interrupt/event block diagram. The diagram shows the internal architecture of the EXTI. At the top, an APB bus is connected to a Peripheral interface. The Peripheral interface is connected to six registers: Falling trigger selection register, Rising trigger selection register, Software interrupt event register, Event mask register, Interrupt mask register, and Pending request register. The Falling and Rising trigger selection registers are connected to an Edge detect circuit. The Software interrupt event register is connected to an OR gate. The Event mask register is connected to an AND gate. The Interrupt mask register is connected to an AND gate. The Pending request register is connected to an OR gate. The Edge detect circuit is connected to Configurable events. The Stop mode input is connected to an AND gate. The Rising edge detect is connected to the AND gate. The AND gate is connected to the OR gate. The OR gate is connected to Interrupts. The AND gate is connected to Events. The OR gate is connected to Wakeup. The diagram is labeled MS33393V1.

13.3.2 Wakeup event management

The STM32L41xxx/42xxx/43xxx/44xxx/45xxx/46xxx is able to handle external or internal events in order to wake up the core (WFE). The wakeup event can be generated either by:

13.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.

13.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.

13.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).

13.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).

13.4 EXTI interrupt/event line mapping

In the STM32L41xxx/42xxx/43xxx/44xxx/45xxx/46xxx, 38 interrupt/event lines are available. The GPIOs are connected to 16 configurable interrupt/event lines (see Figure 29 ).

Figure 29. External interrupt/event GPIO mapping

Diagram showing the mapping of GPIO pins to EXTI lines. It illustrates how pins PA0-PE0 are mapped to EXTI0, PA1-PE1 to EXTI1, and so on up to PA15-PE15 mapped to EXTI15. Each mapping is controlled by bits in the SYSCFG_EXTICR registers (EXTICR1 for lines 0-11 and EXTICR4 for lines 12-15).

The diagram illustrates the mapping of GPIO pins to EXTI lines. It shows three examples of multiplexers:

Vertical ellipsis between EXTI1 and EXTI15 indicates that the same pattern repeats for lines 2 through 14. Source: MSV37629V1.

Diagram showing the mapping of GPIO pins to EXTI lines. It illustrates how pins PA0-PE0 are mapped to EXTI0, PA1-PE1 to EXTI1, and so on up to PA15-PE15 mapped to EXTI15. Each mapping is controlled by bits in the SYSCFG_EXTICR registers (EXTICR1 for lines 0-11 and EXTICR4 for lines 12-15).

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

Table 52. EXTI lines connections

EXTI lineLine source (1)Line type
0-15GPIOconfigurable
16PVDconfigurable
17USB FS wakeup event (3)(2)direct
18RTC alarmsconfigurable
19RTC tamper or timestamp or CSS_LSEconfigurable
20RTC wakeup timerconfigurable
21COMP1 outputconfigurable
22COMP2 outputconfigurable
23I2C1 wakeup (3)direct

Table 52. EXTI lines connections (continued)

EXTI lineLine source (1)Line type
24I2C2 wakeup (3)(4)direct
25I2C3 wakeupdirect
26USART1 wakeup (3)direct
27USART2 wakeup (3)direct
28USART3 wakeup (3)(4)direct
30--
29UART4 wakeup (3)(5)direct
31LPUART1 wakeupdirect
32LPTIM1direct
33LPTIM2 (6)direct
34SWPMI1 wakeup (3)(7)direct
35PVM1 wakeupconfigurable
36--
37PVM3 wakeupconfigurable
38PVM4 wakeupconfigurable
39LCD wakeup (8)direct
40I2C4 wakeup (5)direct
  1. 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. 2. Not available for STM32L431xx devices.
  3. 3. This line source cannot wake up from the Stop 2 mode.
  4. 4. Not available on STM32L432xx and STM32L442xx devices.
  5. 5. Available on STM32L45xxx and STM32L46xxx devices only.
  6. 6. This line can wake up from Stop 2 mode on STM32L41xxx and STM32L42xx devices only.
  7. 7. Available on STM32L43xxx and STM32L44xxx devices only.
  8. 8. Available on STM32L4x3 devices only.

13.5 EXTI registers

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

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

13.5.1 Interrupt mask register 1 (EXTI_IMR1)

Address offset: 0x00

Reset value: 0xFF82 0000

31302928272625242322212019181716
IM31Res.Res.IM28IM27IM26IM25IM24IM23IM22IM21IM20IM19IM18IM17IM16
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
IM15IM14IM13IM12IM11IM10IM9IM8IM7IM6IM5IM4IM3IM2IM1IM0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 IM31 : Interrupt Mask on line 31

0: Interrupt request from Line 31 is masked

1: Interrupt request from Line 31 is not masked

Bits 30:29 Reserved, must be kept at reset value.

Bits 28:0 IMx : Interrupt Mask on line x (x = 28 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.

13.5.2 Event mask register 1 (EXTI_EMR1)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
EM31Res.Res.EM28EM27EM26EM25EM24EM23EM22EM21EM20EM19EM18EM17EM16
rwrwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
EM15EM14EM13EM12EM11EM10EM9EM8EM7EM6EM5EM4EM3EM2EM1EM0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 EM31 : Event mask on line 31

Bits 30:29 Reserved, must be kept at reset value.

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

13.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)

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)

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.

13.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.

13.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).

13.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.

13.5.7 Interrupt mask register 2 (EXTI_IMR2)

Address offset: 0x20

Reset value: 0x0000 0087

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.IM39IM38IM37IM36IM35IM34IM33IM32
rwrwrwrwrwrwrwrw

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

Bits 7:0 IMx : Interrupt mask on line x (x = 39 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 39,) is set to '1' in order to enable the interrupt by default.

13.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.Res.EM39EM38EM37EM36EM35EM34EM33EM32
rwrwrwrwrwrwrwrw

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

Bits 7:0 EMx : Event mask on line x (x = 39 to 32)

0: Event request from line x is masked

1: Event request from line x is not masked

13.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.

13.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.

13.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.

13.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.

13.5.13 EXTI register map

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

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

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00EXTI_IMR1IM31ResResIM28IM27IM26IM25IM24IM23IM22IM21IM20IM19IM18IM17IM16IM15IM14IM13IM12IM11IM10IM9IM8IM7IM6IM5IM4IM3IM2IM1IM0
Reset value111111100000100000000000000000
0x04EXTI_EMR1EM31ResResEM28EM27EM26EM25EM24EM23EM22EM21EM20EM19EM18EM17EM16EM15EM14EM13EM12EM11EM10EM9EM8EM7EM6EM5EM4EM3EM2EM1EM0
Reset value000000000000000000000000000000
0x08EXTI_RTSR1ResResResResResResResResResRT22RT21RT20RT19RT18ResRT16RT15RT14RT13RT12RT11RT10RT9RT8RT7RT6RT5RT4RT3RT2RT1RT0
Reset value0000000000000000000000
0x0CEXTI_FTSR1ResResResResResResResResResFT22FT21FT20FT19FT18ResFT16FT15FT14FT13FT12FT11FT10FT9FT8FT7FT6FT5FT4FT3FT2FT1FT0
Reset value0000000000000000000000
0x10EXTI_SWIER1ResResResResResResResResResSWI22SWI21SWI20SWI19SWI18ResSWI16SWI15SWI14SWI13SWI12SWI11SWI10SWI9SWI8SWI7SWI6SWI5SWI4SWI3SWI2SWI1SWI0
Reset value0000000000000000000000
0x14EXTI_PR1ResResResResResResResResResPIF22PIF21PIF20PIF19PIF18ResPIF16PIF15PIF14PIF13PIF12PIF11PIF10PIF9PIF8PIF7PIF6PIF5PIF4PIF3PIF2PIF1PIF0
Reset value0000000000000000000000
0x20EXTI_IMR2ResResResResResResResResResResResResResResResResResResResResResResResResIM39IM38IM37IM36IM35IM34IM33IM32
Reset value10000111
0x24EXTI_EMR2ResResResResResResResResResResResResResResResResResResResResResResResResEM39EM38EM37EM36EM35EM34EM33EM32
Reset value00000000
0x28EXTI_RTSR2ResResResResResResResResResResResResResResResResResResResResResResResResRT38RT37RT36RT35ResResResRes
Reset value0000
0x2CEXTI_FTSR2ResResResResResResResResResResResResResResResResResResResResResResResResFT38FT37FT36FT35ResResResRes
Reset value0000
0x30EXTI_SWIER2ResResResResResResResResResResResResResResResResResResResResResResResResSWI38SWI37SWI36SWI35ResResResRes
Reset value0000
0x34EXTI_PR2ResResResResResResResResResResResResResResResResResResResResResResResResPIF38PIF37PIF36PIF35ResResResRes
Reset value0000

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