我板子上有多个按键,我都使用中断方式处理。我发现,初始化NVIC时,三个按键如果或上时,如图,就不进中断了,如下图所示: NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn|EXTI1_IRQn|EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); 如果分开初始化就ok了: NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel =EXTI15_10_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); 其实不仅仅是nvic,还有exti 的初始化也要分开,不然就会导致进不了中断或者是按K1按键也会进入K2 中断。 so, 我想问一句,为神马???? |
EXTI0_IRQn是6 EXTI1_IRQn是7 这两个相或一下是几?这已经变成另外一个值了 而不是这两个值的或
这个和引脚初始化不一样 引脚初始化的每一位代表一个引脚 但这个不是 所以这个不可以用或
评分
查看全部评分