cancel
Showing results for 
Search instead for 
Did you mean: 

EXTI15_10 not triggered by user button on NUCLEO-F429ZI

Fnx_QT
Associate III

Hello,

I'm trying to setup interrupts using the user push button (B1) on the Nucleo-F429ZI board. The push button is connected to the microcontroller through the I/O line PC13.

What I did is that I mapped the PC13 to the GPIO_EXTI15 in STM32CubeMX and enabled the NVIC interrupt for EXTI15_10. Then I regenerated the code which gave me the following function in main:

static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
 
  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_ENABLE();
 
  /*Configure GPIO pin : PC13 */
  GPIO_InitStruct.Pin = GPIO_PIN_13;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
 
  /* EXTI interrupt init*/
  HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);
  HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
 
}

I call it in the main after initializing the clocks. However, after the function has been executed, pressing the button does not trigger an interrupt. I enabled interrupt tracing and I can see that the interrupt is never triggered and my callback is therefor never called.

Did I do something wrong ? Thank you.

22 REPLIES 22

I verified the stm32f4xx_hal_gpio.c and exti.c and they are exactly the same. the hal configuration is also the same.

You use latest MX and FW ?

How optimize level.

Your code in main can be optimized out and MCU halt...

Fnx_QT
Associate III

Yes I use the latest update. No the main is not optimized out cause I can place breakpoints inside the GPIO initialization methods. That's really strange.

Yes I use the latest update. No the main is not optimized out cause I can place breakpoints inside the GPIO initialization methods. That's really strange.

while is optimized not all main.

Open example code for your nucleo from repository and try learn exti from it.

Projects/STM32F429ZI-Nucleo/Examples/GPIO/GPIO_EXTI/

Read out and check/post EXTI and relevant GPIO registers content.

In debugger, check that the respective bit in GPIO_IDR changes when button is pressed.

Here are some general steps when interrupts not fire.

JW

Enabling EXTI line[15:10] is 1 of 2 things that needs to be enabled. I believe by default External Event Mode is enabled but you want External Interrupt Mode.

0693W00000Y7zRmQAJ.png

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

I posted before I saw this post, but yeah that is what I was talking about.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

Using the debugger I can see that the bit IDR13 in GPIOC is set everytime I press the button and unset as soon as I release it.

In the EXTI registers I can also see that the IMR (Interrupt Mask Register) is set to 1 for line 13, thus not masking interrupt from line 13.

The RTSR (Rising Trigger Selection Register) is set to 1 for line 13, so rising trigger exception are enabled.

The FTSR (Falling Trigger) is set to 0 for line 13.

Software Interrupt Event Register (SWIER) is set to 0 for line 13.

The Pending Register (PR) is set to 1, it's interesting cause I cannot disable it, it reenables itself directly if I uncheck it.

Are interrupts enabled at all? Call HAL_Delay(10) before MX_GPIO_Init.