11. Interrupts and events

11.1 Nested vectored interrupt controller (NVIC)

11.1.1 NVIC main features

The NVIC and the processor core interface are closely coupled, which enables low latency interrupt processing and efficient processing of late arriving interrupts.

All interrupts including the core exceptions are managed by the NVIC. For more information on exceptions and NVIC programming, refer to the PM0214 programming manual .

11.1.2 SysTick calibration value register

The SysTick calibration value is set to 9000, which gives a reference time base of 1 ms with the SysTick clock set to 9 MHz (max \( f_{HCLK}/8 \) ).

11.1.3 Interrupt and exception vectors

Table 28 is the vector table for STM32F37xxx devices.

Table 28. List of vectors

PositionPriorityType of priorityAcronymDescriptionAddress
----Reserved0x0000 0000
--3fixedResetReset0x0000 0004
--2fixedNMINon maskable interrupt. The RCC Clock Security System (CSS) is linked to the NMI vector.0x0000 0008
--1fixedHardFaultHardware fault0x0000 000C
-0fixedMemManageMPU fault0x0000 0010
-1settableBusFaultPrefetch fault or memory access error0x0000 0014
-2settableUsageFaultUndefined instruction or illegal state0x0000 0018

Table 28. List of vectors (continued)

PositionPriorityType of priorityAcronymDescriptionAddress
-3settableSVCallSystem service call via SWI instruction0x0000 002C
-4settableDebugMonitorDebug monitor0x0000 0030
-5settablePendSVPendable request for system service0x0000 0038
-6settableSysTickSystem tick timer0x0000 003C
07settableWWDGWindow Watchdog interrupt0x0000 0040
18settablePVDPower voltage detector through EXTI line detection interrupt0x0000 0044
29settableTAMPTamper and timestamp through EXTI19 line0x0000 0048
310settableRTC_WKUPRTC0x0000 004C
411settableFLASHFlash global interrupt0x0000 0050
512settableRCCRCC global interrupt0x0000 0054
613settableEXTI0EXTI Line 0 interrupt0x0000 0058
714settableEXTI1EXTI Line 1 interrupt0x0000 005C
815settableEXTI2_TSEXTI Line 2 and routing interface interrupt0x0000 0060
916settableEXTI3EXTI Line 3 interrupt0x0000 0064
1017settableEXTI4EXTI Line 4 interrupt0x0000 0068
1118settableDMA1_CH1DMA1 channel 1 interrupt0x0000 006C
1219settableDMA1_CH2DMA1 channel 2 interrupt0x0000 0070
1320settableDMA1_CH3DMA1 channel 3 interrupt0x0000 0074
1421settableDMA1_CH4DMA1 channel 4 interrupt0x0000 0078
1522settableDMA1_CH5DMA1 channel 5 interrupt0x0000 007C
1623settableDMA1_CH6DMA1 channel 6 interrupt0x0000 0080
1724settableDMA1_CH7DMA1 channel 7 interrupt0x0000 0084
1825settableADC1ADC1 interrupt0x0000 0088
1926settableCAN_TXCAN_TX interrupt0x0000 008C
2027settableCAN_RXDCAN_RXD interrupt0x0000 0090
2128settableCAN_RXICAN_RXI interrupt0x0000 0094
2229settableCAN_SCECAN_SCE interrupt0x0000 0098

Table 28. List of vectors (continued)

PositionPriorityType of priorityAcronymDescriptionAddress
2330settableEXTI5_9EXTI Line[9:5] interrupts0x0000 009C
2431settableTIM15Timer 15 global interrupt0x0000 00A0
2532settableTIM16Timer 16 global interrupt0x0000 00A4
2633settableTIM17Timer 17 global interrupt0x0000 00A8
2734settableTIM18_DAC2Timer 18 global interrupt/DAC2 underrun interrupt0x0000 00AC
2835settableTIM2Timer 2 global interrupt0x0000 00B0
2936settableTIM3Timer 3 global interrupt0x0000 00B4
3037settableTIM4Timer 4 global interrupt0x0000 00B8
3138settableI2C1_EVI2C1_EV global interrupt/EXTI Line[3:2] interrupts0x0000 00BC
3239settableI2C1_ERI2C1_ER0x0000 00C0
3340settableI2C2_EVI2C2_EV global interrupt/EXTI Line[4:2] interrupts0x0000 00C4
3441settableI2C2_ERI2C2_ER0x0000 00C8
3542settableSPI1SPI1 global interrupt0x0000 00CC
3643settableSPI2SPI2 global interrupt0x0000 00D0
3744settableUSART1USART1 global interrupt/EXTI25 (USART1 wakeup event)0x0000 00D4
3845settableUSART2USART2 global interrupt/EXTI26 (USART2 wakeup event)0x0000 00D8
3946settableUSART3USART3 global interrupt/EXTI28 (USART3 wakeup event)0x0000 00DC
4047settableEXTI15_10EXTI Line[15:10] interrupts0x0000 00E0
4148settableRTC_ALARM_ITRTC alarm interrupt0x0000 00E4
4249settableCECCEC interrupt0x0000 00E8
4350settableTIM12Timer 12 global interrupt0x0000 00EC
4451settableTIM13Timer 13 global interrupt0x0000 00F0
4552settableTIM14Timer 14 global interrupt0x0000 00F4
46-4953-56Reserved0x0000 00F8-
0x0000 0104
5057settableTIM5Timer 5 global interrupt0x0000 0108
5158settableSPI3SPI3 global interrupt0x0000 010C

Table 28. List of vectors (continued)

PositionPriorityType of priorityAcronymDescriptionAddress
52-5359-60Reserved0x0000 0110-
0x0000 0114
5461settableTIM6_DAC1Timer 6 global interrupt/DAC1 underrun interrupt0x0000 0118
5562settableTIM7Timer 7 global interrupt0x0000 011C
5663settableDMA2_CH1DMA2 channel 1 interrupt0x0000 0120
5764settableDMA2_CH2DMA2 channel 2 interrupt0x0000 0124
5865settableDMA2_CH3DMA2 channel 3 interrupt0x0000 0128
5966settableDMA2_CH4DMA2 channel 4 interrupt0x0000 012C
6067settableDMA2_CH5DMA2 channel 5 interrupt0x0000 0130
6168settableSDADC1ADC sigma delta 1 (SDADC1) global interrupt0x0000 0134
6269settableSDADC2ADC sigma delta 2 (SDADC2) global interrupt0x0000 0138
6370settableSDADC3ADC sigma delta 1 (SDADC3) global interrupt0x0000 013C
6471settableCOMP1_2Comparator 1/comparator 2 global interrupts (EXTI21/EXTI22)0x0000 0140
65-7372-80Reserved0x0000 0144-
0x0000 0164
7481settableUSB_HPUSB high priority interrupt0x0000 0168
7582settableUSB_LPUSB low priority interrupt0x0000 016C
7683settableUSB_WAKEUPUSB wakeup interrupt0x0000 0170
7784Reserved0x0000 0174
7885settableTIM19Timer 19 global interrupt0x0000 0178
79-8086-87Reserved0x0000 017C-
0x0000 0180
8188settableFPUFloating point unit interrupt0x0000 0184

11.2 Extended interrupts and events controller (EXTI)

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

The EXTI allows the management of up to 29 external/internal event line (21 external event lines and 8 internal event lines).

The active edge of each external interrupt line can be chosen independently, whilst for internal interrupt the active edge is always the rising one. An interrupt could be left pending: in case of an external one, a status register is instantiated and indicates the source of the interrupt; an event is always a simple pulse and it is used for triggering the core Wake-up. For internal interrupts, the pending status is assured by the generating IP, so no need for a specific flag. Each input line can be masked independently for interrupt or event generation. In addition, the internal lines are sampled only in STOP mode. This controller also allows to emulate the (only) external events by software, multiplexed with the corresponding hardware event line, by writing to a dedicated register.

11.2.1 Main features

The EXTI main features are the following:

11.2.2 Block diagram

The extended interrupt/event block diagram is shown in Figure 25 .

Figure 25. EXTI extended interrupt/event block diagram

Figure 25. EXTI extended interrupt/event block diagram. The diagram shows the internal architecture of the EXTI peripheral. At the top, an AMBA APB bus is connected to a Peripheral interface. The Peripheral interface is also connected to a PCLK input and has five 29-bit wide registers: Pending request register, Interrupt mask register, Software interrupt event Register, Rising trigger selection register, and Falling trigger selection register. The Pending request register is connected to the NVIC interrupt controller. The Interrupt mask register, Software interrupt event Register, Rising trigger selection register, and Falling trigger selection register are connected to an Edge detect circuit. The Edge detect circuit is connected to an Input line. The Software interrupt event Register is also connected to a Pulse generator. The Pulse generator is connected to an Event mask register. The Event mask register is connected to the Edge detect circuit. The Edge detect circuit is connected to the Pending request register. The diagram is labeled MS19982V1.
Figure 25. EXTI extended interrupt/event block diagram. The diagram shows the internal architecture of the EXTI peripheral. At the top, an AMBA APB bus is connected to a Peripheral interface. The Peripheral interface is also connected to a PCLK input and has five 29-bit wide registers: Pending request register, Interrupt mask register, Software interrupt event Register, Rising trigger selection register, and Falling trigger selection register. The Pending request register is connected to the NVIC interrupt controller. The Interrupt mask register, Software interrupt event Register, Rising trigger selection register, and Falling trigger selection register are connected to an Edge detect circuit. The Edge detect circuit is connected to an Input line. The Software interrupt event Register is also connected to a Pulse generator. The Pulse generator is connected to an Event mask register. The Event mask register is connected to the Edge detect circuit. The Edge detect circuit is connected to the Pending request register. The diagram is labeled MS19982V1.

11.2.3 Wake-up event management

The STM32F37xxx is able to handle external or internal events to wake up the core (WFE). The wake-up event can be generated either by:

11.2.4 Asynchronous Internal Interrupts

Some communication peripherals (UART, I2C, CEC) 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 is asked to generate both a synchronized (to the system clock, for example, the APB clock) and an asynchronous version of the event.

11.2.5 Functional description

For the external interrupt lines, to generate the interrupt, the interrupt line should be configured and enabled. 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 external interrupt line, an interrupt request is generated. The pending bit corresponding to the interrupt line is also set. This request is reset by writing a '1' in the pending register.

For the internal interrupt lines, the active edge is always the rising edge. The interrupt is enabled by default in the interrupt mask register and there is no corresponding pending bit in the pending register.

To generate the 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 external 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 internal lines can be triggered only when the system is in STOP mode. If the system is still running, no interrupt/event is generated.

Hardware interrupt selection

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

Hardware event selection

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

Software interrupt/event selection

Any of the external lines can be configured as software interrupt/event lines. The following is the procedure to generate a software interrupt.

11.2.6 External and internal interrupt/event line mapping

In the STM32F37xxx, 29 interrupt/event lines are available: 8 lines are internal (including the reserved ones) and the remaining 21 lines are external.

The GPIOs are connected to the 16 external interrupt/event lines in the following manner:

Figure 26. Extended interrupt/event GPIO mapping

Diagram showing the mapping of GPIO pins to external interrupt lines (EXTI).

The diagram illustrates the mapping of GPIO pins to external interrupt lines (EXTI) through multiplexers. Each multiplexer is controlled by configuration bits in the SYSCFG_EXTICR registers.

Vertical ellipses between EXTI1 and EXTI15 indicate that the same pattern repeats for EXTI2 through EXTI14. The diagram is labeled with MS19951V3 in the bottom right corner.

Diagram showing the mapping of GPIO pins to external interrupt lines (EXTI).

The remaining lines are connected as follows:

Note: EXTI lines 23, 24, 25, 26, 27, and 28 are internal.

11.3 EXTI registers

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

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

11.3.1 Interrupt mask register (EXTI_IMR)

Address offset: 0x00

Reset value: 0x1F80 0000 (See note below)

31302928272625242322212019181716
Res.Res.Res.MR28MR27MR26MR25MR24MR23MR22MR21MR20MR19MR18MR17MR16
rwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
MR15MR14MR13MR12MR11MR10MR9MR8MR7MR6MR5MR4MR3MR2MR1MR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:29 Reserved, must be kept at reset value (0).

Bits 28:0 MRx : Interrupt Mask on external/internal line x

0: Interrupt request from Line x is masked

1: Interrupt request from Line x is not masked

Note: The reset value for the internal lines (23, 24, 25, 26, 27 and 28) is set to '1' to enable the interrupt by default.

11.3.2 Event mask register (EXTI_EMR)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.MR28MR27MR26MR25MR24MR23MR22MR21MR20MR19MR18MR17MR16
rwrwrwrwrwrwrwrwrwrwrwrwrw

1514131211109876543210
MR15MR14MR13MR12MR11MR10MR9MR8MR7MR6MR5MR4MR3MR2MR1MR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:29 Reserved, must be kept at reset value (0).

Bits 28:0 MRx : Event mask on external/internal line x

0: Event request from Line x is masked

1: Event request from Line x is not masked

11.3.3 Rising trigger selection register (EXTI_RTSR)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.TR22TR21TR20TR19TR18TR17TR16
rwrwrwrwrwrwrw
1514131211109876543210
TR15TR14TR13TR12TR11TR10TR9TR8TR7TR6TR5TR4TR3TR2TR1TR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 22:0 TRx : Rising trigger event configuration bit of line x (x = 22 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 external wake-up lines are edge triggered. No glitches must be generated on these lines. If a rising edge on an external 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.

11.3.4 Falling trigger selection register (EXTI_FTSR)

Address offset: 0x0C

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.TR22TR21TR20TR19TR18TR17TR16
rwrwrwrwrwrwrw
1514131211109876543210
TR15TR14TR13TR12TR11TR10TR9TR8TR7TR6TR5TR4TR3TR2TR1TR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 22:0 TRx : Falling trigger event configuration bit of line x (x = 22 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 external wake-up lines are edge triggered. No glitches must be generated on these lines. If a falling edge on an external 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.

11.3.5 Software interrupt event register (EXTI_SWIER)

Address offset: 0x10
Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SWIER 22SWIER 21SWIER 20SWIER 19SWIER 18SWIER 17SWIER 16
rwrwrwrwrwrwrw
1514131211109876543210
SWIER 15SWIER 14SWIER 13SWIER 12SWIER 11SWIER 10SWIER 9SWIER 8SWIER 7SWIER 6SWIER 5SWIER 4SWIER 3SWIER 2SWIER 1SWIER 0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 22:0 SWIERx : Software interrupt on line x (x = 22 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).

11.3.6 Pending register (EXTI_PR)

Address offset: 0x14
Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.PR22PR21PR20PR19PR18PR17PR16
rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1
1514131211109876543210
PR15PR14PR13PR12PR11PR10PR9PR8PR7PR6PR5PR4PR3PR2PR1PR0
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:0 PRx : Pending bit on line x (x = 22 to 0)

0: No trigger request occurred

1: selected trigger request occurred

This bit is set when the selected edge event arrives on the external interrupt line.

This bit is cleared by writing a 1 into the bit.

11.3.7 EXTI register map

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

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

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00EXTI_IMRRes.Res.Res.MR[28:0]
Reset value1111110000000000000000000000
0x04EXTI_EMRRes.Res.Res.MR[28:0]
Reset value0000000000000000000000000000
0x08EXTI_RTSRRes.Res.Res.Res.Res.Res.Res.Res.Res.TR[22:0]
Reset value0000000000000000000000
0x0CEXTI_FTSRRes.Res.Res.Res.Res.Res.Res.Res.Res.TR[22:0]
Reset value0000000000000000000000
0x10EXTI_SWIERRes.Res.Res.Res.Res.Res.Res.Res.Res.SWIER[22:0]
Reset value0000000000000000000000
0x14EXTI_PRRes.Res.Res.Res.Res.Res.Res.Res.Res.PR[22:0]
Reset value0000000000000000000000

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