cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot Read PA1 Button State or Print Debug Logs in STM32WB05KZ BLE RC Peripheral Project

pradeepaan
Associate III

 

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 OK

After 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.


Does anyone know:

  1. Why APP_DBG_MSG prints only once?

  2. Where is the correct place to add periodic debug logs in the BLE WB05 project?

  3. Do I need to enable any UART / trace settings for continuous debug output?

  4. 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.

See also posting preformatted text other than source code.

1 REPLY 1
pradeepaan
Associate III

my code

pradeepaan_0-1765196226136.png

output

pradeepaan_1-1765196268593.png