这里最终是把RTC和TIM3都是设置成抢占优先级1,响应优先级7。
//参考手册上代码如下
NVIC_InitTypeDef NVIC_InitStructure;
- /* Configure the Priority Grouping with 1 bit */
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
- /* Enable tiM3 global interrupt with Preemption Priority 0 and SubPriority as 2 */
- NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQChannel;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
- NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
- NVIC_InitStructure(&NVIC_InitStructure);
- /* Enable USART1 global interrupt with Preemption Priority 1 and SubPriority as 5 */
- NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
- NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
- NVIC_InitStructure(&NVIC_InitStructure);
- /* Enable RTC global interrupt with Preemption Priority 1 and SubPriority as 7 */
- NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQChannel;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 7;
- NVIC_InitStructure(&NVIC_InitStructure);
- /* Enable EXTI4 interrupt with Preemption Priority 1 and SubPriority as 7 */
- NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQChannel;
- NVIC_InitStructure.NVIC_IRQChannelSubPriority = 7;
- NVIC_InitStructure(&NVIC_InitStructure);
- /* TIM3 interrupt priority is higher than USART1, RTC and EXTI4 interrupts priorities. USART1 interrupt priority is higher than RTC and EXTI4 interrupts priorities. RTC interrupt priority is higher than EXTI4 interrupt prioriy. */
更多回帖