8. Interrupts and events

Low-density value line devices are STM32F100xx microcontrollers where the flash memory density ranges between 16 and 32 Kbytes.

Medium-density value line devices are STM32F100xx microcontrollers where the flash memory density ranges between 64 and 128 Kbytes.

High-density value line devices are STM32F100xx microcontrollers where the flash memory density ranges between 256 and 512 Kbytes.

This section applies to the whole STM32F100xx family, unless otherwise specified.

8.1 Nested vectored interrupt controller (NVIC)

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 STM32F100xx Cortex®-M3 programming manual (see Related documents on page 1 ).

8.1.1 SysTick calibration value register

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

8.1.2 Interrupt and exception vectors

Table 50. Vector table for STM32F100xx devices

PositionPriorityType of priorityAcronymDescriptionAddress
----Reserved0x0000_0000
--3fixedResetReset0x0000_0004

Table 50. Vector table for STM32F100xx devices (continued)

PositionPriorityType of priorityAcronymDescriptionAddress
--2fixedNMI_HandlerNon maskable interrupt. The RCC Clock Security System (CSS) is linked to the NMI vector.0x0000_0008
--1fixedHardFault_HandlerAll class of fault0x0000_000C
-0settableMemManage_HandlerMemory management0x0000_0010
-1settableBusFault_HandlerPre-fetch fault, memory access fault0x0000_0014
-2settableUsageFault_HandlerUndefined instruction or illegal state0x0000_0018
----Reserved0x0000_001C - 0x0000_002B
-3settableSVC_HandlerSystem service call via SWI instruction0x0000_002C
-4settableDebugMon_HandlerDebug Monitor0x0000_0030
----Reserved0x0000_0034
-5settablePendSV_HandlerPendable request for system service0x0000_0038
-6settableSysTick_HandlerSystem tick timer0x0000_003C
07settableWWDGWindow Watchdog interrupt0x0000_0040
18settablePVDPVD through EXTI Line detection interrupt0x0000_0044
29settableTAMPER_STAMPTamper and TimeStamp through EXTI line interrupts0x0000_0048
310settableRTC_WKUPRTC Wakeup through EXTI line interrupt0x0000_004C
411settableFLASHFlash global interrupt0x0000_0050
512settableRCCRCC global interrupt0x0000_0054
613settableEXTI0EXTI Line0 interrupt0x0000_0058
714settableEXTI1EXTI Line1 interrupt0x0000_005C
815settableEXTI2EXTI Line2 interrupt0x0000_0060
916settableEXTI3EXTI Line3 interrupt0x0000_0064
1017settableEXTI4EXTI Line4 interrupt0x0000_0068
1118settableDMA1_Channel1DMA1 Channel1 global interrupt0x0000_006C
1219settableDMA1_Channel2DMA1 Channel2 global interrupt0x0000_0070

Table 50. Vector table for STM32F100xx devices (continued)

PositionPriorityType of priorityAcronymDescriptionAddress
1320settableDMA1_Channel3DMA1 Channel3 global interrupt0x0000_0074
1421settableDMA1_Channel4DMA1 Channel4 global interrupt0x0000_0078
1522settableDMA1_Channel5DMA1 Channel5 global interrupt0x0000_007C
1623settableDMA1_Channel6DMA1 Channel6 global interrupt0x0000_0080
1724settableDMA1_Channel7DMA1 Channel7 global interrupt0x0000_0084
1825settableADC1ADC1 global interrupt0x0000_0088
----Reserved0x0000_008C -
0x0000_0098
2330settableEXTI9_5EXTI Line[9:5] interrupts0x0000_009C
2431settableTIM1_BRK_TIM15TIM1 Break and TIM15 global interrupt0x0000_00A0
2532settableTIM1_UP_TIM16TIM1 Update and TIM16 global interrupts0x0000_00A4
2633settableTIM1_TRG_COM_TIM17TIM1 Trigger and Commutation and TIM17 global interrupts0x0000_00A8
2734settableTIM1_CCTIM1 Capture Compare interrupt0x0000_00AC
2835settableTIM2TIM2 global interrupt0x0000_00B0
2936settableTIM3TIM3 global interrupt0x0000_00B4
3037settableTIM4TIM4 global interrupt0x0000_00B8
3138settableI2C1_EVI 2 C1 event interrupt0x0000_00BC
3239settableI2C1_ERI 2 C1 error interrupt0x0000_00C0
3340settableI2C2_EVI 2 C2 event interrupt0x0000_00C4
3441settableI2C2_ERI 2 C2 error interrupt0x0000_00C8
3542settableSPI1SPI1 global interrupt0x0000_00CC
3643settableSPI2SPI2 global interrupt0x0000_00D0
3744settableUSART1USART1 global interrupt0x0000_00D4
3845settableUSART2USART2 global interrupt0x0000_00D8
3946settableUSART3USART3 global interrupt0x0000_00DC
4047settableEXTI15_10EXTI Line[15:10] interrupts0x0000_00E0
4148settableRTC_AlarmRTC Alarms (A and B) through EXTI line interrupt0x0000_00E4
4249settableCECCEC global interrupt0x0000_00E8

Table 50. Vector table for STM32F100xx devices (continued)

PositionPriorityType of priorityAcronymDescriptionAddress
4350settableTIM12TIM12 global interrupt0x0000_00EC
4451settableTIM13TIM13 global interrupt0x0000_00F0
4552settableTIM14TIM14 global interrupt0x0000_00F4
----Reserved0x0000_00F8 -
0x0000_00FC
4855settableFSMCFSMC global interrupt0x0000_0100
----Reserved0x0000_0104
5057settableTIM5TIM5 global interrupt0x0000_0108
5158settableSPI3SPI3 global interrupt0x0000_010C
5259settableUART4UART4 global interrupt0x0000_0110
5360settableUART5UART5 global interrupt0x0000_0114
5461settableTIM6_DACTIM6 global and DAC underrun interrupts0x0000_0118
5562settableTIM7TIM7 global interrupt0x0000_011C
5663settableDMA2_Channel1DMA2 Channel1 global interrupt0x0000_0120
5764settableDMA2_Channel2DMA2 Channel2 global interrupt0x0000_0124
5865settableDMA2_Channel3DMA2 Channel3 global interrupt0x0000_0128
5966settableDMA2_Channel4_5DMA2 Channel4 and DMA2 Channel5 global interrupts0x0000_012C
6067settableDMA2_Channel5 (1)DMA2 Channel5 global interrupt0x0000_0130
  1. 1. For High-density value line devices, the DMA2 Channel 5 is mapped at position 60 only if the MISC_REMAP bit in the AFIO_MAPR2 register is set and DMA2 Channel 2 is connected with DMA2 Channel 4 at position 59 when the MISC_REMAP bit in the AFIO_MAPR2 register is reset.

8.2 External interrupt/event controller (EXTI)

The external interrupt/event controller consists of up to 18 edge detectors for generating event/interrupt requests. Each input line can be independently configured to select the type (event or interrupt) and the corresponding trigger event (rising or falling or both). Each line can also be masked independently. A pending register maintains the status line of the interrupt requests

8.2.1 Main features

The EXTI controller main features are the following:

8.2.2 Block diagram

The block diagram is shown in Figure 18 .

Figure 18. External interrupt/event controller block diagram

Block diagram of the External interrupt/event controller (EXTI) showing its internal architecture and connections.

The block diagram illustrates the internal architecture of the External interrupt/event controller (EXTI). At the top, the AMBA APBbus is connected to a Peripheral interface . The PCLK2 clock signal is also input to this interface. Below the interface, five 18-bit wide registers are shown: Pending request register , Interrupt mask register , Software interrupt event register , Rising trigger selection register , and Falling trigger selection register . These registers are connected to the Peripheral interface and to various logic blocks. The Pending request register outputs to the To NVIC interrupt controller . The Interrupt mask register and Software interrupt event register are inputs to an AND gate. The output of this AND gate is connected to an OR gate. The Rising trigger selection register and Falling trigger selection register are inputs to an Edge detect circuit , which receives signals from Input Line s. The output of the Edge detect circuit is also connected to the OR gate. The Event mask register is an input to the OR gate. The output of the OR gate is connected to a second AND gate. The Pulse generator is an input to this second AND gate. The output of the second AND gate is connected to the To NVIC interrupt controller . Bus widths are indicated by a slash and the number 18 on the signal lines.

Block diagram of the External interrupt/event controller (EXTI) showing its internal architecture and connections.

8.2.3 Wakeup event management

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

To use an external line as a wakeup event, refer to Section 8.2.4: Functional description .

8.2.4 Functional description

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.

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

An interrupt/event request can also be generated by software by writing a '1' in the software interrupt/event register.

Hardware interrupt selection

To configure the 18 lines as interrupt sources, use the following procedure:

Hardware event selection

To configure the 18 lines as event sources, use the following procedure:

Software interrupt/event selection

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

8.2.5 External interrupt/event line mapping

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

Figure 19. External interrupt/event GPIO mapping

Diagram showing the mapping of external interrupt/event lines (EXTI0, EXTI1, and EXTI15) to various GPIO pins (PA, PB, PC, PD, PE, PF, PG) via multiplexers controlled by AFIO_EXTICR registers.

The diagram illustrates the mapping of external interrupt/event lines to GPIO pins. It consists of three multiplexer blocks, each controlled by a specific register bit field:

A vertical dashed line between the EXTI1 and EXTI15 blocks indicates that the same mapping logic applies to the intermediate interrupt lines (EXTI2 through EXTI14).

Diagram showing the mapping of external interrupt/event lines (EXTI0, EXTI1, and EXTI15) to various GPIO pins (PA, PB, PC, PD, PE, PF, PG) via multiplexers controlled by AFIO_EXTICR registers.
  1. 1. To configure the AFIO_EXTICRx for the mapping of external interrupt/event lines onto GPIOs, the AFIO clock should first be enabled. Refer to Section 6.3.7: APB2 peripheral clock enable register (RCC_APB2ENR) .

The two other EXTI lines are connected as follows:

8.3 EXTI registers

Refer to Section 1.1 on page 32 for a list of abbreviations used in register descriptions.
The peripheral registers have to be accessed by words (32-bit).

8.3.1 Interrupt mask register (EXTI_IMR)

Address offset: 0x00
Reset value: 0x0000 0000

31302928272625242322212019181716
ReservedMR17MR16
rwrw
1514131211109876543210
MR15MR14MR13MR12MR11MR10MR9MR8MR7MR6MR5MR4MR3MR2MR1MR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 17:0 MRx : Interrupt Mask on line x
0: Interrupt request from Line x is masked
1: Interrupt request from Line x is not masked

8.3.2 Event mask register (EXTI_EMR)

Address offset: 0x04
Reset value: 0x0000 0000

31302928272625242322212019181716
ReservedMR17MR16
rwrw
1514131211109876543210
MR15MR14MR13MR12MR11MR10MR9MR8MR7MR6MR5MR4MR3MR2MR1MR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 17:0 MRx : Event mask on line x
0: Event request from Line x is masked
1: Event request from Line x is not masked

8.3.3 Rising trigger selection register (EXTI_RTSR)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
ReservedTR17TR16
rwrw
1514131211109876543210
TR15TR14TR13TR12TR11TR10TR9TR8TR7TR6TR5TR4TR3TR2TR1TR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 17:0 TRx : Rising trigger event configuration bit of line x

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 wakeup lines are edge triggered, no glitches must be generated on these lines. If a rising edge on external interrupt line occurs during writing of 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.

8.3.4 Falling trigger selection register (EXTI_FTSR)

Address offset: 0x0C

Reset value: 0x0000 0000

31302928272625242322212019181716
ReservedTR17TR16
rwrw
1514131211109876543210
TR15TR14TR13TR12TR11TR10TR9TR8TR7TR6TR5TR4TR3TR2TR1TR0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 17:0 TRx : Falling trigger event configuration bit of line x

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

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

Note: The external wakeup lines are edge triggered, no glitches must be generated on these lines. If a falling edge on external interrupt line occurs during writing of 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.

8.3.5 Software interrupt event register (EXTI_SWIER)

Address offset: 0x10
Reset value: 0x0000 0000

31302928272625242322212019181716
ReservedSWIER
17
SWIER
16
rwrw
1514131211109876543210
SWIER
15
SWIER
14
SWIER
13
SWIER
12
SWIER
11
SWIER
10
SWIER
9
SWIER
8
SWIER
7
SWIER
6
SWIER
5
SWIER
4
SWIER
3
SWIER
2
SWIER
1
SWIER
0
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

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

Bits 17:0 SWIERx : Software interrupt on line x

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)

8.3.6 Pending register (EXTI_PR)

Address offset: 0x14
Reset value: undefined

31302928272625242322212019181716
ReservedPR17PR16
rc_w1rc_w1
1514131211109876543210
PR15PR14PR13PR12PR11PR10PR9PR8PR7PR6PR5PR4PR3PR2PR1PR0
rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1rc_w1

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

Bits 17:0 PRx : Pending bit

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.

8.3.7 EXTI register map

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

Table 51. External interrupt/event controller register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00EXTI_IMRReservedMR[17:0]
Reset value00000000000000000000000000000000
0x04EXTI_EMRReservedEMR[17:0]
Reset value00000000000000000000000000000000
0x08EXTI_RTSRReservedRTSR[17:0]
Reset value00000000000000000000000000000000
0x0CEXTI_FTSRReservedFTSR[17:0]
Reset value00000000000000000000000000000000
0x10EXTI_SWIERReservedSWIER[17:0]
Reset value00000000000000000000000000000000
0x14EXTI_PRReservedPR[17:0]
Reset value00000000000000000000000000000000

Refer to Table 1 on page 37 and Table 2 on page 38 for the register boundary addresses.