- <p>//参考手册上代码如下</p><p>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 <font color="red">RTC</font> <font color="red">global interrupt</font> 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. <font color="red">RTC interrupt priority is higher than EXTI4 interrupt prioriy.</font> */
- </p>
复制代码
这里最终是把RTC和TIM3都是设置成抢占优先级1,响应优先级7。
1.RTC interrupt priority is higher than EXTI4 interrupt prioriy.是不是错了?
2.global interrupt和普通中断有有什么区别吗?你是如何理解global interrupt的?
3.还有两个通道可以设置成一种优先级吗??
一周热门 更多>