12. Extended interrupt and event controller (EXTI)

12.1 Introduction

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 plus a wake-up request to the power controller.

The EXTI allows the management of up to 30 event lines which can wake up the device from Stop mode.

Some of the lines are configurable: in this case the active edge can be chosen independently, and a status flag indicates the source of the interrupt. The configurable lines are used by the I/Os external interrupts, and by few peripherals. Some of the lines are direct: they are used by some peripherals to generate a wakeup from Stop event or interrupt. In this case the status flag is provided by the peripheral.

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

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

12.2 EXTI main features

The EXTI main features are the following:

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

12.3.1 EXTI block diagram

The block diagram is shown in Figure 27 .

Block diagram of the Extended Interrupts and Events Controller (EXTI).

Figure 27. Extended interrupts and events controller (EXTI) block diagram

The diagram illustrates the internal architecture of the EXTI. At the top, an APB bus is connected via a bidirectional arrow to a Peripheral interface , which also receives a PCLK clock signal. Below the interface, six registers are shown with bidirectional arrows to the interface: Falling trigger selection register , Rising trigger selection register , Software interrupt event register , Event mask register , Interrupt mask register , and Pending request register .
The logic flow is as follows:
1. Configurable events enter an Edge detect circuit , which is controlled by the Falling and Rising trigger selection registers.
2. The output of the edge detect circuit, along with the Software interrupt event register, goes into an OR gate.
3. The output of this OR gate splits: one path goes to an AND gate with the Interrupt mask register to set the Pending request register , which then outputs Interrupts . Another path goes to an AND gate with the Event mask register to output Events .
4. Direct events enter an AND gate with a Stop mode signal. The output goes to a Rising edge detect. block.
5. The output of the Rising edge detect block is combined via OR gates with the outputs of the mask-controlled AND gates to produce a Wakeup signal.
The identifier MSv32798V1 is in the bottom right corner.

Block diagram of the Extended Interrupts and Events Controller (EXTI).

12.3.2 Wakeup event management

The STM32L0x1 microcontrollers are able to handle external or internal events in order to wake up the core (WFE). The wakeup event can be generated by either:

12.3.3 Peripherals asynchronous interrupts

Some peripherals can generate events when the system is in Run mode or in Stop mode, thus 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 required to allow the wakeup from Stop mode.

12.3.4 Hardware interrupt selection

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

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

The direct lines do not require any EXTI configuration.

For code example, refer to A.7.2: Extended interrupt selection code example .

12.3.5 Hardware event selection

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

  1. 1. Configure the mask bits of the Event lines (EXTI_EMR)
  2. 2. Configure the Trigger Selection bits of the Event lines (EXTI_RTSR and EXTI_FTSR).

12.3.6 Software interrupt/event selection

Any of the configurable lines can be configured as software interrupt/event lines. The procedure below must be followed to generate a software interrupt.

  1. 1. Configure the mask bits of the Interrupt/Event lines (EXTI_IMR, EXTI_EMR)
  2. 2. Set the required bit in the software interrupt register (EXTI_SWIER).

12.4 EXTI interrupt/event line mapping

In the STM32L0x1, 30 interrupt/event lines are available. The GPIOs are connected to 16 configurable interrupt/event lines as shown in Figure 28 .

Figure 28. Extended interrupt/event GPIO mapping

Diagram showing the mapping of GPIO pins to EXTI interrupt lines. It illustrates four examples: EXTI0 (PA0, PB0, PC0), EXTI1 (PA1, PB1, PC1), EXTI2 (PA2, PB2, PC2, PD2), and EXTI15 (PA15, PB15, PC15). Each line is controlled by bits in the SYSCFG_EXTICR registers.

The diagram illustrates the mapping of GPIO pins to EXTI interrupt lines. It shows four specific examples, with vertical ellipses indicating the continuation of the pattern for the remaining lines.

MSV34757V1

Diagram showing the mapping of GPIO pins to EXTI interrupt lines. It illustrates four examples: EXTI0 (PA0, PB0, PC0), EXTI1 (PA1, PB1, PC1), EXTI2 (PA2, PB2, PC2, PD2), and EXTI15 (PA15, PB15, PC15). Each line is controlled by bits in the SYSCFG_EXTICR registers.

Note: Refer to the datasheet for the list of available I/O ports.

The 30 lines are connected as shown in Table 54: EXTI lines connections :

Table 54. EXTI lines connections
EXTI lineLine sourceLine type
0-15GPIOconfigurable
16PVDconfigurable
17RTC alarmconfigurable
18Reserved
19RTC tamper or timestamp or
CSS_LSE
configurable
20RTC wakeup timerconfigurable
21COMP1 outputconfigurable
22COMP2 outputconfigurable
23I2C1 wakeupdirect
24I2C3 wakeupdirect
25USART 1 wakeupdirect
26USART2 wakeupdirect
27Reserved
28LPUART1 wakeupdirect
29LPTIM1 wakeupdirect

12.5 EXTI registers

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

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

12.5.1 EXTI interrupt mask register (EXTI_IMR)

Address offset: 0x00
Reset value: 0x3F84 0000

31302928272625242322212019181716
Res.Res.IM29IM28Res.IM26IM25IM24IM23IM22IM21IM20IM19Res.IM17IM16
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
IM15IM14IM13IM12IM11IM10IM9IM8IM7IM6IM5IM4IM3IM2IM1IM0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 29:28 IMx : Interrupt mask on line x (x = 29 to 28)
0: Interrupt request from Line x is masked
1: Interrupt request from Line x is not masked

Bit 27 Reserved, must be kept at reset value.

Bits 26:19 IMx : Interrupt mask on line x (x = 26 to 19)
0: Interrupt request from Line x is masked
1: Interrupt request from Line x is not masked

Bit 18 Reserved, must be kept at reset value.

Bits 17:0 IMx : Interrupt mask on line x (x = 17 to 0)
0: Interrupt request from Line x is masked
1: Interrupt request from Line x is not masked

12.5.2 EXTI event mask register (EXTI_EMR)

Address offset: 0x04
Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.EM29EM28Res.EM26EM25EM24EM23EM22EM21EM20EM19Res.EM17EM16
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
EM15EM14EM13EM12EM11EM10EM9EM8EM7EM6EM5EM4EM3EM2EM1EM0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

12.5.3 EXTI rising edge trigger selection register (EXTI_RTSR)

Address offset: 0x08
Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.RT22RT21RT20RT19Res.RT17RT16
151413121110987654RT16210
RT15RT14RT13RT12RT11RT10RT9RT8RT7RT6RT5RT4RT3RT2RT1RT0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Note: The configurable wakeup lines are edge triggered, no glitch must be generated on these lines.
If a rising edge on the configurable interrupt line occurs while writing to the EXTI_RTSR register, the pending bit will not be set.
Rising and falling edge triggers can be set for the same interrupt line. In this configuration, both generate a trigger condition.

12.5.4 Falling edge trigger selection register (EXTI_FTSR)

Address offset: 0x0C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.FT22FT21FT20FT19Res.FT17FT16
rwrwrwrwrwrw
1514131211109876543210
FT15FT14FT13FT12FT11FT10FT9FT8FT7FT6FT5FT4FT3FT2FT1FT0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

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

Bit 18 Reserved, must be kept at reset value.

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

Note: The configurable wakeup lines are edge triggered, no glitch must be generated on these lines.

If a falling edge on the configurable interrupt line occurs while writing to the EXTI_FTSR register, the pending bit will not be set.

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

12.5.5 EXTI software interrupt event register (EXTI_SWIER)

Address offset: 0x10

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SWI22SWI21SWI20SWI19Res.SWI17SWI16
rwrwrwrwrwrw
1514131211109876543210
SWI15SWI14SWI13SWI12SWI11SWI10SWI9SWI8SWI7SWI6SWI5SWI4SWI3SWI2SWI1SWI0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 22:19 SWIx : Software interrupt on line x (x = 22 to 19)

Writing a 1 to this bit when it is at 0 sets the corresponding pending bit in EXTI_PR. If the interrupt is enabled on this line in EXTI_IMR and EXTI_EMR, an interrupt request is generated.

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

Bit 18 Reserved, must be kept at reset value.

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

Writing a 1 to this bit when it is at 0 sets the corresponding pending bit in EXTI_PR. If the interrupt is enabled on this line in EXTI_IMR and EXTI_EMR, an interrupt request is generated.

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

12.5.6 EXTI pending register (EXTI_PR)

Address offset: 0x14

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.PIF22PIF21PIF20PIF19Res.PIF17PIF16
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:19 PIFx : Pending interrupt flag on line x (x = 22 to 19)

0: No trigger request occurred

1: The selected trigger request occurred

This bit is set when the selected edge event arrives on the interrupt line. This bit is cleared by writing it to 1 or by changing the sensitivity of the edge detector.

Bit 18 Reserved, must be kept at reset value.

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

0: No trigger request occurred

1: The selected trigger request occurred

This bit is set when the selected edge event arrives on the interrupt line. This bit is cleared by writing it to 1 or by changing the sensitivity of the edge detector.

12.5.7 EXTI register map

The following table gives the EXTI register map and the reset values.

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

OffsetRegister313029282726252423222120191817161514131211109876543210
Res.Res.IM[29:28]Res.IM[26:19]Res.IM[17:0]
0x00EXTI_IMR
Reset value1 11 1 1 1 0 0 0 00 0 0 0 0 0 0 0 0 0
0x04EXTI_EMREM[29:28]Res.EM[26:19]Res.EM[17:0]
Reset value0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0
0x08EXTI_RTSRRes.Res.Res.Res.Res.Res.Res.RT[22:19]Res.RT[17:0]
Reset value0 0 0 00 0 0 0 0 0 0 0 0 0
0x0CEXTI_FTSRRes.Res.Res.Res.Res.Res.Res.FT[22:19]Res.FT[17:0]
Reset value0 0 0 00 0 0 0 0 0 0 0 0 0
0x10EXTI_SWIERRes.Res.Res.Res.Res.Res.Res.SWI [22:19]Res.SWI[17:0]
Reset value0 0 0 00 0 0 0 0 0 0 0 0 0
0x14EXTI_PRRes.Res.Res.Res.Res.Res.Res.PIF [22:19]Res.PIF[17:0]
Reset value0 0 0 00 0 0 0 0 0 0 0 0 0

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