在做外部中断初始化时遇见这样的问题,对PB0 PB1设置成外部中断,初始化NVIC时直接写成 NVIC_InitStructure.NVIC_IRQChannel=EXTI0_IRQn|EXTI1_IRQn; 不能正常进中断
唯一的区别就是把 NVIC_InitStructure.NVIC_IRQChannel分开了,想问一下有谁知道这是为什么?
正常代码
[mw_shl_code=c,true] NVIC_InitStructure.NVIC_IRQChannel=EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x01;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x02;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel=EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x01;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x02;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);[/mw_shl_code]
不正常代码
[mw_shl_code=c,true] NVIC_InitStructure.NVIC_IRQChannel=EXTI0_IRQn|EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x01;
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x02;
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);[/mw_shl_code]
|