interruptstm32irq

STM32L4R5xx hangs when an external interrupt is enabled


I would like to use the pin PC3 as an external interrupt. Whenever I enable the interrupt I end up in the infinite loop.

This is how I init a gpio and its interrupt:

__HAL_RCC_GPIOC_CLK_ENABLE();
 GPIO_InitStruct.Pin = GPIO_PIN_3;
 GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
 GPIO_InitStruct.Pull = GPIO_NOPULL;
 HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 /* EXTI interrupt init*/
 HAL_NVIC_SetPriority(EXTI3_IRQn, 0, 0);
 HAL_NVIC_EnableIRQ(EXTI3_IRQn);

I have checked hardware and all signals are like they should be. I tried PB0 and PC3 and the result is the same.

Anyone who knows how to play with stm32l4 and exti?

The infinite loop:

Default_Handler:
Infinite_Loop:
    b   Infinite_Loop
    .size   Default_Handler, .-Default_Handler

I dont even reach an interrupt here (I have a break point there)

void EXIT3_IRQnHandler(void)
{
    HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
    if(!HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_3))
    {
               HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_7);
               HAL_GPIO_TogglePin(GPIOG, GPIO_PIN_14);
    }
    EXTI_ClearITPendingBit(EXTI3_IRQn);
}

Maybe that is important to mention that I also have SPI configuration in the same project (SPI1).


Solution

  • If ISR name is not correct it will use some default error code (its name depends on configuration), as happens in your case.

    In my code its named EXTI3_IRQHandler not EXTI3_IRQnHandler.

    Check in your startup file (in my setup it is called startup_stm32l432xx.s) for ISR names to be used.