2025-12-08 4:12 AM - last edited on 2025-12-08 4:32 AM by Andrew Neil
Hi everyone,
I’m working with the STM32WB05KZ using the BLE RC Peripheral example from STM32CubeMX.
I added a push button on PA1 and an LED on PA0.
My goal:
Read PA1 button state
Turn ON LED on PA0 when button is pressed
Send BLE notification to the central device
Continuously print PA1 state every 1 second on the serial monitor
Here is the code snippet:
APP_DBG_MSG("SW1 OK\n");
uint32_t lastPrint = 0; // Print every 1 second
if ((HAL_GetTick() - lastPrint) >= 1000)
{
lastPrint = HAL_GetTick();
uint8_t state = HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_1);
APP_DBG_MSG("PA1 State = %d\n", state);
}
while (1) { // Needed for BLE MX_APPE_Process(); }The output I get is:
aci_gap_configure_filter_accept_and_resolving_list command
==>> End BLE_Init function
Services and Characteristics creation
Success: aci_gatt_srv_add_service command:
RC_LR_Periph
End of Services and Characteristics creation
Success: aci_hal_set_radio_activity_mask command
==>> Success: aci_gap_set_advertising_configuration
==>> Success: aci_gap_set_advertising_data
==>> Success: aci_gap_set_advertising_enable
SW1 OKAfter that, I never see “PA1 State = …”.
No further serial output.
I tried placing the print inside the while loop and outside the loop, but still no data in the serial monitor.
Why APP_DBG_MSG prints only once?
Where is the correct place to add periodic debug logs in the BLE WB05 project?
Do I need to enable any UART / trace settings for continuous debug output?
Is MX_APPE_Process() blocking the CPU?
Any suggestions or example code would be appreciated.
Thank you!
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-12-08 4:18 AM - last edited on 2025-12-08 4:32 AM by Andrew Neil
my code
output