Most learning boards use the Nvic group configuration in the initialization file for each peripheral when configuring interrupt priority for each peripheral, such as the configuration of Nvic in both the ADC and Usart as follows:
In the ADC:
void Adc_nvic_configuration (void)
{
Nvic_inittypedef nvic_initstructure;
Nvic_prioritygroupconfig (NVIC_PRIORITYGROUP_0);
Nvic_initstructure.nvic_irqchannel =adc1_2_irqn; Turn on Adc_channel8 interrupts
nvic_initstructure.nvic_irqchannelpreemptionpriority = 0;
nvic_initstructure.nvic_irqchannelsubpriority = 1;
Nvic_initstructure.nvic_irqchannelcmd = ENABLE;
Nvic_init (&nvic_initstructure);
}
In Usart:
void Nvic_configuration (void)
{
/* struct declaration */
Nvic_inittypedef nvic_initstructure;
/* Configure the NVIC preemption priority Bits */
/* Configure one bit for preemption priority */
/* Priority group describes the number of bits used for preemption priority, and the number of bits used in response priority here is 0, 4
0 Groups: Preemption priority is 0 bits, response priority is 4 bits
1 Groups: preemption priority is 1 bits, response priority is 3 bits
2 Groups: preemption priority is 2 bits, response priority is 2 bits
3 groups: Preemption priority is 3 bits, response priority is 1 bits
4 groups: preemption priority is 4 bits, response priority is 0 bits
*/
Nvic_prioritygroupconfig (NVIC_PRIORITYGROUP_0);
Nvic_initstructure.nvic_irqchannel = USART1_IRQN; Set up serial 1 interrupts
nvic_initstructure.nvic_irqchannelpreemptionpriority = 0; Preemption Priority 0
nvic_initstructure.nvic_irqchannelsubpriority = 0; Sub-priority is 0
Nvic_initstructure.nvic_irqchannelcmd = ENABLE; To enable
Nvic_init (&nvic_initstructure);
}
However, in practice this configuration is unreasonable, that is, if you assume that two Nvic are configured with different interrupt groups, a conflict may occur if one of the peripherals references a value other than the priority allowed by the last configuration interrupt group. After discussing with the teacher, he thought that if the priority of the previous initialization was unreasonable than the value set by the following priority group, the previous interrupt might not be able to respond, but .....
In my experiment I found that changing the order of the two priority configurations anyway seemed to have no effect on my program results.
Of course, the teacher's advice is to set up Systemconfig files in the project to configure interrupt priority groups and clocks, that is, interrupt priority group configuration occurs only once,