|
|||
Introduction to Interrupts & EXTI: Interrupt and NVIC for STM32F4xx family microcontroller: Interrupts are important for microcontrollers and processors. For example; someone calling you while you can playing game in phone, firstly you make a phone call then you can continue your game. In this case, the call will be priority. We say the interrupt to priority status. In case of interrupt, stop main program and jump to interrupt subprogram (executing this program) and subprogram is finished, it continues where it left off. (return main program) NVIC (Nested Vectored Interrupt Controller):
The NVIC supports up to 240 interrupts each with up to 256 levels of priority. You can change the priority of an interrupt dynamically. STM32 has a higher-priority interrupts. STM32 uses 4 bits define priority level. misc.h library priority level definition shown below;
Pre-emption priority level ability of one interrupt to interrupt another interrupt. When you use USART- ADC interrupts, you can configure pre-emption priority level. The subpriority level value is used only when two same preempt priority occurred at the same time. When you use USART1- USART2 interrupts, you can configure subpriority priority level. For example you select priority group 1, you use 1 bit pre-emption priority, 3 bit subpriority. EXTI Each STM32F4 device has 23 external interrupt or event sources that can be generate interrupt request upon edge detector. The EXTI controller block diagram shown below (from reference manual);There are 23 external interupt lines and 16 external interrupt lines connected with GPIO pins. PA0,PB0,etc. connected the line 0 and PA15,PB15,etc. connected line 15. When we need to EXTI0, we can use either PA0,PB0,etc. We don’t use PB0 and PA0 simultaneously. The seven other EXTI lines are connected as follows:
EXTI line 16 is connected to the PVD output EXTI Code Example: I will use use PA0 for external interrupt in stm32f407 microcontroller. When push the user button on stm32f4 discovery board LED4 (Green LED, connected to PD12) will toggle.
Library dependencies
THE END.
Useful link for good information about EXTI: http://armprogramming.com/stm32f4-discovery-tutorials-interruptexti/ Sharif University of Technology, Tehran, Iran |