This is an old revision of the document!
Nested Vectored Interrupt Controller
The NVIC manages all the interrupts and is closely coupled to the processor core.
A list of all available interrupts: interrupt table.
Features
- 91 maskable interrupt channels.
- 16 programmable priority levels.
- low-latency exceptions and interrupt handling.
Programming Example
For external interrupts via GPIO pins go to the EXTI page.
Setup Peripheral (e.g. Timer 2)
#include "reg_stm32f4xx.h" RCC->APB1ENR |= (0x1 << 0u); /* Enable TIM2 clock. */ /* configure timer */ TIM2->PSC = 84000u - 1u; /* Counting with f = 84MHz / 84000 = 1MHz */ TIM2->ARR = 512u; /* Count to 512 */ TIM2->DIER |= (0x1 << 0u); /* Enable IRQ */ TIM2->CR1 |= (0x1 << 0u); /* Start timer */
Setup NVIC
#include "reg_stm32f4xx.h" NVIC->ISER[0] |= (0x1 << 28u); /* Enable TIM2 global interrupt. */