The NVIC helps the processor handle many interrupt signals quickly and in order. It decides which interrupt to handle first so the system works smoothly.
NVIC (Nested Vectored Interrupt Controller) in ARM Architecture
NVIC_EnableIRQ(IRQn_Type IRQn); NVIC_DisableIRQ(IRQn_Type IRQn); NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority); NVIC_GetPriority(IRQn_Type IRQn); NVIC_ClearPendingIRQ(IRQn_Type IRQn); NVIC_SetPendingIRQ(IRQn_Type IRQn);
IRQn_Type is the interrupt number or name for a specific interrupt source.
Priority is usually a number where lower means higher priority.
NVIC_EnableIRQ(TIM2_IRQn);
NVIC_SetPriority(USART1_IRQn, 1);NVIC_DisableIRQ(EXTI0_IRQn);
This simple program enables the interrupt for an external line (like a button). It sets the priority so the processor knows how important this interrupt is compared to others. The main loop waits for interrupts to happen.
#include "stm32f4xx.h" int main(void) { // Enable interrupt for external line 0 (e.g., a button press) NVIC_EnableIRQ(EXTI0_IRQn); // Set priority to 2 (lower number means higher priority) NVIC_SetPriority(EXTI0_IRQn, 2); // Main loop while (1) { // Wait for interrupts } return 0; }
NVIC is part of ARM Cortex-M processors and manages interrupts efficiently.
Lower priority numbers mean higher priority interrupts.
Always enable the interrupt and set its priority before expecting it to work.
NVIC controls how the processor handles multiple interrupts.
It allows setting priorities to decide which interrupt to handle first.
Use NVIC functions to enable, disable, and prioritize interrupts in ARM Cortex-M systems.