2025-01-29 02:49 AM - last edited on 2025-01-29 09:07 AM by SofLit
Hi
I'm using nucleo_u575zi board. Connected three external switches to PB0, PB1 & PB2 pins.
By default, the pins are low, the pins are configured as:
/*Configure GPIO pins : EXT_PIN3_Pin EXT_PIN1_Pin EXT_PIN2_Pin */
GPIO_InitStruct.Pin = EXT_PIN3_Pin|EXT_PIN1_Pin|EXT_PIN2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
The NVIC is also enabled. The EXT callback is not getting triggered, not sure what is the issue and how to verify that in debug mode whether it's getting called or not, can someone help me to debug and trace what might be the issue.
Attaching the main.c and .ioc files below.
Thankyou.
2025-01-29 02:55 AM - edited 2025-01-29 03:02 AM
Hello,
You didn't set any internal pull down to any of EXTI inputs:
GPIO_InitStruct.Pull = GPIO_NOPULL
Did you connect pull-down resistors to these inputs?
You may also refer to this example using EXTI on NUCLEO-U575 board and use the callback as provided in the example:
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == BUTTON_USER_PIN)
{
/* Toggle LED1 */
BSP_LED_Toggle(LED1);
}
}
An there are two callback one for the rising and another for falling edges:
HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
HAL_GPIO_EXTI_Rising_Callback(uint16_t GPIO_Pin)
In your case you need to use HAL_GPIO_EXTI_Rising_Callback().
Hope that helps.