5. NVIC
The interrupt vector nesting controller is used to manage all interrupts and events, including interrupt enable and disable, and interrupt priority. This belongs to the kernel, so ST's reference manual has little description of it, but it is very important. To understand it, you need to read ARM's "Cortex™-M4 Devices Generic User Guide".
Related registers
Translated from "Cortex™-M4 Devices Generic UserGuide". If there are any errors, please refer to the original text.
Interrupt enable register NVIC_ISER[8]
There are 8 interrupt enable registers in total. ISER[0] sets the enable of interrupts 0 to 31, ISER[1] sets the enable of interrupts 32 to 63, and so on. The following takes ISER[0] as an example:
[31:0] SETENA Interrupt Set Enable Bit.
Write:
0 = No effect
1 = Enable interrupt.
Read:
0 = Interrupt is disabled
1 = Interrupt is enabled
To enable interrupt 0, write 1 to bit 0 of the register. To enable interrupt 38, write 1 to bit 6 of NVIC_ISER[1], and so on. For information on which interrupt corresponds to which interrupt number, refer to the Position column in Chapter 9, Table 30. Vector table in the reference manual "RM0090 Reference manual".
Interrupt disable register NVIC_ICER[8]
There are 8 interrupt disable registers in total. ICER[0] sets interrupts 0 to 31 to disable, ICER[1] sets interrupts 32 to 63 to enable, and so on. The following takes ICER[0] as an example:
[31:0] SETENA Interrupt Set Enable Bit.
Write:
0 = No effect
1 = Disable interrupt.
Read:
0 = Interrupt is disabled
1 = Interrupt is enabled
The following registers are all 8, only ***R[0] is used as an example
Interrupt pending setting register NVIC_ISPR[8]
[31:0] SETPEND interrupt pending set bit.
Write:
0 = No effect
1 = Change interrupt status to pending.
Read:
0 = Interrupt is not pending
1 = Interrupt is waiting to be processed.
Release interrupt pending register NVIC_ICPR[8]
[31:0] CLRPEND interrupt clear pending bit.
Write:
0 = No effect
1 = Remove pending state of interrupt.
Read:
0 = No interrupt is pending
1 = Interrupt is pending.
Interrupt activation bit register NVIC_IABR[8]
[31:0] Interrupt active flag:
0 = Interrupt inactive
1 = Interrupt active.
Reading this bit will read 1 if the corresponding interrupt status is as an active or active and pending.
Interrupt Priority Register NVIC_IPR[60]
The interrupt priority registers are 60 32-bit registers, and the st structure uses 240 8-bit byte arrays NVIC->IP[240] to map them, each corresponding to an interrupt priority.
There are two types of ARM interrupt priorities: preemption priority and response priority.
An interrupt with a high preemptive priority can be responded to during the interrupt processing with a low preemptive priority, that is, interrupt nesting, or an interrupt with a high preemptive priority can nest an interrupt with a low preemptive priority.
When the preemptive priority of two interrupt sources is the same, there will be no nesting relationship between the two interrupts. When one interrupt arrives, if another interrupt is being processed, the later interrupt will have to wait until the previous interrupt is processed. If the two interrupts arrive at the same time, the interrupt controller decides which one to process first based on their response priority; if their preemptive priority and response priority are equal, the order of their ranking in the interrupt table determines which one to process first.
Interrupt priority grouping is to divide the priority register, separating which bits are response priority and which bits are preemption priority. As for how to set the grouping, it depends on a register that does not belong to NVIC.
Application interrupt and reset control register SCB_AIRCR
What we need to look at here are bits [31:16] and [10:8]. Bits [31:16] are identification codes used to protect this register from accidental modification, and bits [10:8] are the setting bits for the interrupt priority grouping.
[31:16]
Write: VECTKEYSTAT
Read: VECTKEY
RW Registration key:
Read as 0xFA05
When writing, write 0x05FA to VECTKEY, otherwise the write will be ignored.
[10:8] Interrupt priority
Each ARM M4 interrupt priority is designed to be 8-bit programmable. Specifically, stm32f4 only leaves 4 bits of 16 levels of programmable priority for the user, of which the lower 4 bits are occupied. That is to say, the priority grouping of stm32f4 is shown in the following table:
[10:8] | Split Point | Preemption priority bit | Response priority bit | Preemption priority number | Response priority number |
0b011 | xxxx | [7:4] | none | 16 | 1 |
0b100 | xxx.y | [7:5] | [4] | 8 | 2 |
0b101 | xx.yy | [7:6] | [5:4] | 4 | 4 |
0b110 | x.yyy | [7] | [6:4] | 2 | 8 |
0b111 | yyyy | none | [7:4] | 1 | 16 |
The last NVIC register
Software trigger interrupt register NVIC_STIR
When the USERSETMPEND bit of SCB_CCR is 1, unprivileged user programs can write to this register.
[31:9] Reserved.
[8:0] INTID ID number interrupt trigger,
range 0-239. For example, 0x03 specifies interrupt IRQ3 trigger.
Previous article:EXTI (operation register) of stm32f407
Next article:DAC of stm32f407 (operation register)
Recommended ReadingLatest update time:2024-11-16 20:47
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Questions about creating schematic package in Orcad
- EEWORLD University Hall----Live Replay: Dadatong helps you unlock the new generation of ADAS technology
- What are the six axes in a six-axis robot?
- Three-phase sensorless sine wave BLDC drive (MS39549 and MS39545)
- October 21 Live Review: ADI Inertial MEMS Applications (including video, presentation documents, Q&A)
- Altium selects the schematic device and automatically highlights the corresponding PCB device. How to set it?
- Pre-registration for the prize live broadcast | TI uses DLP micro-projection technology to design augmented reality smart glasses
- Please recommend some technical public accounts and recent thoughts
- Come here to apply for the DFRobot Xingkong board~
- Which one has a 50 ohm impedance matching circuit? Please refer to it.