AnsweredAssumed Answered

EXTI_IRQ with USerButton problem

Question asked by kecskes.gergely on Oct 31, 2015
Latest reply on May 31, 2016 by Lukasz Przenioslo
Hello there!

I have designed a custom board, and what I'd like to do is that when I press the UserButton, a LED lights up. Now, my button is connected to PC0 pin on my STM32F429 controller, and the LED is connected to PB7 pin. 

What my problem is, that every time I press the button, I get unexpected interrupt, and I'll end up in startup_stm32.s 'Infinite_Loop'. I have no idea what I'm doing wrong, my code is based on cubef4  GPIO example.

main.c

void Button_init()
{
    GPIO_InitTypeDef GPIO_init;
 
    __HAL_RCC_GPIOC_CLK_ENABLE();
 
    GPIO_init.Mode = GPIO_MODE_IT_FALLING;
    GPIO_init.Pin = GPIO_PIN_0;
    GPIO_init.Pull = GPIO_NOPULL;
 
    HAL_GPIO_Init(GPIOC, &GPIO_init);
 
    HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(EXTI0_IRQn);
}
 
void LED_init()
{
    GPIO_InitTypeDef GPIO_init;
 
    __HAL_RCC_GPIOB_CLK_ENABLE();
 
    GPIO_init.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_init.Pin = GPIO_PIN_7;
    GPIO_init.Pull = GPIO_NOPULL;
    GPIO_init.Speed = GPIO_SPEED_FAST;
 
    HAL_GPIO_Init(GPIOB, &GPIO_init);
}
 
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
    if(GPIO_Pin == GPIO_PIN_0)
    {
        HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
    }
}


stm32f4xx_it.c
void EXTI0_IRQHandler(void)
{
    HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
}

Do you guys know what causes my external interrupt failure? There must something wrong with the NVIC settings, or so...

Thanks for the help in advanced!


Outcomes