[中断]设置问题

2019-07-14 22:52发布

  1. <p>//参考手册上代码如下</p><p>NVIC_InitTypeDef NVIC_InitStructure;
  2. /* Configure the Priority Grouping with 1 bit */
  3. NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);


  4. /* Enable tiM3 global interrupt with Preemption Priority 0 and SubPriority as 2 */
  5. NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQChannel;
  6. NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  7. NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
  8. NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  9. NVIC_InitStructure(&NVIC_InitStructure);


  10. /* Enable USART1 global interrupt with Preemption Priority 1 and SubPriority as 5 */
  11. NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQChannel;
  12. NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
  13. NVIC_InitStructure.NVIC_IRQChannelSubPriority = 5;
  14. NVIC_InitStructure(&NVIC_InitStructure);


  15. /* Enable <font color="red">RTC</font> <font color="red">global interrupt</font> with Preemption Priority 1 and SubPriority as 7 */
  16. NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQChannel;
  17. NVIC_InitStructure.NVIC_IRQChannelSubPriority = 7;
  18. NVIC_InitStructure(&NVIC_InitStructure);


  19. /* Enable EXTI4 interrupt with Preemption Priority 1 and SubPriority as 7 */
  20. NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQChannel;
  21. NVIC_InitStructure.NVIC_IRQChannelSubPriority = 7;
  22. NVIC_InitStructure(&NVIC_InitStructure);


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


0条回答

一周热门 更多>