When configuring the interrupt priority of each peripheral, most development boards used for learning are used to configure the NVIC group in the initialization file of each peripheral. For example, the NVIC configurations of ADC and Usart are as follows:
In ADC:
void ADC_NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel =ADC1_2_IRQn; // Enable ADC_Channel8 interrupt
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
Usart:
void NVIC_Configuration(void)
{
/* Structure declaration */
NVIC_InitTypeDef NVIC_InitStructure;
/* Configure the NVIC Preemption Priority Bits */
/* Configure one bit for preemption priority */
/* The priority group specifies the number of bits used for preemption priority and response priority. Here, it is 0, 4
Group 0: Preemption priority occupies 0 bits, response priority occupies 4 bits
Group 1: Preemption priority occupies 1 bit, response priority occupies 3 bits
Group 2: Preemption priority occupies 2 bits, response priority occupies 2 bits
Group 3: Preemption priority occupies 3 bits, response priority occupies 1 bit
Group 4: Preemption priority occupies 4 bits, response priority occupies 0 bits
*/
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; //Set serial port 1 interrupt
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; //Preemption priority 0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; //Subpriority is 0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //Enable
NVIC_Init(&NVIC_InitStructure);
}
But in fact, this configuration is unreasonable, that is, if the interrupt groups configured by the two NVICs are different, if one of the peripherals references a priority value other than that allowed by the last configured interrupt group, a conflict may occur. After discussing with the teacher, he believes that if the previously initialized priority is unreasonable compared to the value set by the later priority group, the previous interrupt may not be responded to, BUT...
When I was experimenting, I found that no matter how I changed the order of these two priority configurations, it seemed to have no effect on the results of my program.
Of course, the teacher's suggestion is to create a systemconfig file in the project to configure the interrupt priority group and clock, that is, the interrupt priority group configuration only appears once
Previous article:LPC_11C14 platform I2C analysis
Next article:STM32 interrupt setting and interrupt priority setting
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Bird's Linux Private Recipe (Full Version)
- 20 most advanced robots that are a little scary!
- After installing quartus13.1
- ST MEMS Sensor Creative Design Competition is now open for registration, DJI drones, GoPro cameras, Kindles are waiting for you to win...
- [Evaluation of domestic FPGA Gaoyun GW1N-4 series development board]——7. Digital tube display stopwatch
- Question sharing: Zigbee antenna performance
- Detailed analysis of the improvement of the software and hardware architecture of the ARM embedded minimum system
- C6000 Fixed-Point DSP-C645x Application Guide
- What kind of LCD is better?
- How to choose the right inductor for RF circuits