2026-04-21 11:30 PM - last edited on 2026-04-22 6:58 AM by Imen.D
I'm developing using the STM32WBA65I-DK1.
I'd like to know how to implement interrupt handling for button presses.
It appears that stm32wba65i_discovery.h does not contain any APIs related to button presses (which is perhaps to be expected since the DK does not have push buttons).
The sample code I'm using is BLE_HeartRate_Thread. If you have any source code that might be helpful, please let me know.
Solved! Go to Solution.
2026-04-22 2:51 AM
For the STM32WBA65I-DK1 an external button (e.g. the center button of the blue joystick B1) would need to be handled either by GPIO polling or via GPIO EXTI interrupt configuration.
For a simple button input, polling is often the more practical approach. It avoids the additional interrupt load caused by contact bounce and is generally easier to implement and validate.
You could use one of the following methods:
If you still want to try it with an interrupt, you can define the USER_Button (PA3) as EXTI with falling edge (there is already an external pull-ip R56) and enable EXTI3 in the NVIC. The EXTI callback can then be used to set a flag in software, while the actual button action is handled in the main loop:
/* USER CODE BEGIN PV */
volatile uint8_t user_button_pressed = 0; // example flag
/* USER CODE END PV */
/* USER CODE BEGIN 0 */
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_3) user_button_pressed = 1;
}
/* USER CODE END 0 */
In your while loop you could add something like:
while (1)
{
if (user_button_pressed)
{
user_button_pressed = 0; // reset the flag
// ... some button action ...
}
}
If you also want to use the four other buttons on the blue joystick B1, then instead of the method described below, analogue polling of all 5 buttons via the ADC is more appropriate.
Hope that helps?
Regards
/Peter
2026-04-22 2:38 AM
This feature is called EXTI on STM32. Check this example:
2026-04-22 2:51 AM
For the STM32WBA65I-DK1 an external button (e.g. the center button of the blue joystick B1) would need to be handled either by GPIO polling or via GPIO EXTI interrupt configuration.
For a simple button input, polling is often the more practical approach. It avoids the additional interrupt load caused by contact bounce and is generally easier to implement and validate.
You could use one of the following methods:
If you still want to try it with an interrupt, you can define the USER_Button (PA3) as EXTI with falling edge (there is already an external pull-ip R56) and enable EXTI3 in the NVIC. The EXTI callback can then be used to set a flag in software, while the actual button action is handled in the main loop:
/* USER CODE BEGIN PV */
volatile uint8_t user_button_pressed = 0; // example flag
/* USER CODE END PV */
/* USER CODE BEGIN 0 */
void HAL_GPIO_EXTI_Falling_Callback(uint16_t GPIO_Pin)
{
if (GPIO_Pin == GPIO_PIN_3) user_button_pressed = 1;
}
/* USER CODE END 0 */
In your while loop you could add something like:
while (1)
{
if (user_button_pressed)
{
user_button_pressed = 0; // reset the flag
// ... some button action ...
}
}
If you also want to use the four other buttons on the blue joystick B1, then instead of the method described below, analogue polling of all 5 buttons via the ADC is more appropriate.
Hope that helps?
Regards
/Peter
2026-04-27 3:53 PM
Thank you all very much.
I will use your comments as a reference as I proceed with development.