标签:
在测试FreeRTOS在stm32上运行的时候,需要用到timer的中断,则打开了中断,但是如下的代码则让系统死机:
/* 选择优先级分组0 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
/* 开启 TIM2 中断, 0级先占优先级,0级后占优先级 */
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
以上红色标注的优先级设置出问题。
修改如下,则ok
/* 选择优先级分组0 */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
标签:
原文地址:http://www.cnblogs.com/huxiaokang/p/5175609.html