前一段时间都没怎么学F1开发板,这段时间又从新开始学习F1的库,写到外部中断这发现了小问题,我用的另外一个ZET6的核心板写的外部中断,写进去发现只有WK_UP按键按下有效,我看了下程序后发现我的两个按键全部没有把GPIO和中断线映射在一起,但是为什么GPIOA0是有效的,我想可能是因为EXTICR1开机默认中断线0默认在PA0口,然后我就把两个按键IO口和中断线映射好,改了下 GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource2);函数把A映射到中断线2上,程序下进去另一个按键有效了,但是为什么WK_UP按键按下还是有效的,- -我试了下把原子外部中断历程改了吓到战舰V1中发现也是这样的,求解[mw_shl_code=c,true]void EXTI_Init_Config(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
KEY_IO_Config();
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource2);
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_Init(&EXTI_InitStructure);
GPIO_EXTILineConfig(GPIO_PortSourceGPIOE, GPIO_PinSource4);
EXTI_InitStructure.EXTI_Line = EXTI_Line4;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_Init(&NVIC_InitStructure);
} [/mw_shl_code]
我代码中吧WK_UP设置在GPIO_PinSource2,按理说按下WK_UP键应该不会有效的
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>