Question
STM32F4Discovery - Setting up EXTI on external button
Posted on January 27, 2014 at 17:31
I've got the example working using the on board button and now I want to use an external button on CPIOC - 11. I've used this button with GPIO_ReadInputDataBit with PuPd_UP. I've converted over the sample code but I've not getting any interrupt. I thought that the EXTI_Line needs to also be 11 and the EXTILineConfig with GPIOC and PinSource11 but I'm confused with the EXTI Line number and NVIC IRQChannel as it seems there are 5 of them.
Thanks,Jim.GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; /* Enable GPIOA clock */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); /* Enable SYSCFG clock */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Configure PA0 pin as input floating */ GPIO_StructInit(&GPIO_InitStructure); // Reset init structure GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; GPIO_Init(GPIOC, &GPIO_InitStructure); /* Connect EXTI Line0 to PA0 pin */ SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOC, EXTI_PinSource11); /* Configure EXTI Line0 */ EXTI_InitStructure.EXTI_Line = EXTI_Line11; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable and set EXTI Line0 Interrupt to the lowest priority */ NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); #stm32f4discovery-exti-nvic-setup