大神们,我现在在想用PB0和PC0作为外部中断,均下降沿触发,想咨询下 中断初始化的时候需要怎么配,
void EXTIX_Init(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//ê1ÄüSYSCFGê±Öó
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource0);//Pb0 ᬽóμ½ÖD¶ÏÏß0
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource0);//Pc0 ᬽóμ½ÖD¶ÏÏß0
EXTI_InitStructure.EXTI_Line = EXTI_Line0;//LINE0
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//ÖD¶Ïê¼t
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //ϽμÑØ′¥·¢
EXTI_InitStructure.EXTI_LineCmd = ENABLE;//ê1ÄüLINE0
EXTI_Init(&EXTI_InitStructure);//ÅäÖÃ
EXTI_InitStructure.EXTI_Line = EXTI_Line2;//LINE0
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//ÖD¶Ïê¼t
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; //ϽμÑØ′¥·¢
EXTI_InitStructure.EXTI_LineCmd = ENABLE;//ê1ÄüLINE0
EXTI_Init(&EXTI_InitStructure);//ÅäÖÃ
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;//ía2¿ÖD¶Ï0
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;//ÇàÕ¼óÅÏ輶0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//×óóÅÏ輶2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ê1Äüía2¿ÖD¶Ïí¨μà
NVIC_Init(&NVIC_InitStructure);//ÅäÖÃ
NVIC_InitStructure.NVIC_IRQChannel = EXTI2_IRQn;//ía2¿ÖD¶Ï2
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;//ÇàÕ¼óÅÏ輶1
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x02;//×óóÅÏ輶2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ê1Äüía2¿ÖD¶Ïí¨μà
NVIC_Init(&NVIC_InitStructure);//ÅäÖÃ
}
个人觉得应该是这个地方我 SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOB, EXTI_PinSource0);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource0);配置错了手册,顺便求助各位大神,
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
我看手册上面是PA0-PIO是一组,那是不是你要用其中0口作为中断口其他的0口就没办法作为中断中了吗
是这个意思,因为只有那么几个外部中断线。
知道了,没玩过这款单片机,有些东西不确定。。谢谢 ,兄弟
一周热门 更多>