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.

1 ACCEPTED SOLUTION

Accepted Solutions
Fnx_QT
Associate III

I finally found the problem... All the configuration was good, the only thing that broke my system was a preprocessor symbol define that was included in my example project : CMSIS_NVIC_VIRTUAL HSE_VALUE=8000000. I still don't know what purpose it serves.

In addition, the cmsis_nvic_virtual.h was used and some NVIC functions were redefined:

#define NVIC_SetPriorityGrouping    __NVIC_SetPriorityGrouping
#define NVIC_GetPriorityGrouping    __NVIC_GetPriorityGrouping
#define NVIC_EnableIRQ(IRQn)        svcNVIC_func(2U, IRQn)
#define NVIC_GetEnableIRQ           __NVIC_GetEnableIRQ
#define NVIC_DisableIRQ(IRQn)       svcNVIC_func(4U, IRQn)
#define NVIC_GetPendingIRQ          __NVIC_GetPendingIRQ
#define NVIC_SetPendingIRQ          __NVIC_SetPendingIRQ
#define NVIC_ClearPendingIRQ(IRQn)  svcNVIC_func(7U, IRQn)
#define NVIC_GetActive              __NVIC_GetActive
#define NVIC_SetPriority            __NVIC_SetPriority
#define NVIC_GetPriority            __NVIC_GetPriority
#define NVIC_SystemReset            __NVIC_SystemReset

Upon removing these two modifications, the button interrupt is now working correctly.

Thank you all for your help.

View solution in original post

22 REPLIES 22
Karl Yamashita
Lead II

Besides enabling NVIC, did you enable for External Interrupt Mode?

If you find my answers useful, click the accept button so that way others can see the solution.

If by enabling External Interrupt Mode you mean enable EXTI line[15:10] interrupts in the NVIC Interrupt Table, then yes.

If you mean another thing, then I don't what it is and I'm interested.

Fnx_QT
Associate III

Oh and if you meant setting the GPIO mode to External Interrupt Mode with Rising/Falling edge trigger detection, also yes. I tried both with Rising and Falling edge, and both failed.

Sarra.S
ST Employee

Hello @Fnx_QT​ 

You should create a function to handle the EXTI interrupt : void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)

in which you write the code that you want to be executed when the interrupt occurs.

This Wiki can guide you through it step by step

Thank you for your contribution!

Sarra

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @Sarra.S​ ,

Yes I did create and implement the function, the thing is that it's never called as the interrupt is never triggered. In exceptions tracing I always see EXTI15_10 with a count of 0.

Place breakpoint into callback and show how you implement callback.

Simple mistake is change in it file and dont clear flags...

I did place a breakpoint, it doesn't stop inside. As I said earlier, the interruption is not even triggered so the callback could not be called.

However here is the callback:

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  if(GPIO_Pin == GPIO_PIN_13) {
    __NOP();
		int x = 10;
		x++;
  }
}

And the IRQ handler implemented by STM32CubeMX:

/**
  * @brief This function handles EXTI line[15:10] interrupts.
  */
void EXTI15_10_IRQHandler(void)
{
  /* USER CODE BEGIN EXTI15_10_IRQn 0 */
 
  /* USER CODE END EXTI15_10_IRQn 0 */
  HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_13);
  /* USER CODE BEGIN EXTI15_10_IRQn 1 */
 
  /* USER CODE END EXTI15_10_IRQn 1 */
}

My main is very simple for testing purpose:

int main(void)
{
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
 
 int x = 0;
  while (1)
  {
		x++;
  }
}

Push-buttons B1 USER: the user button is connected to the I/O PC13 by default (Tamper support, SB173 ON and SB180 OFF) or PA0 (Wakeup support, SB180 ON and SB173 OFF) of the STM32 microcontroller. Or OFF OFF no connected But

You measure PC13 ?

The button is working, I tested it in another project. It produces correct exceptions. There must a configuration in my project that prevents it from operating correctly but since my main is basically empty I don't know what...