cancel
Showing results for 
Search instead for 
Did you mean: 

LED blink works with CFG_DEBUGGER enabled but not when disabled on STM32WB5MM-DK

nayeemcron
Associate II

I’m developing a custom BLE server on an STM32WB5MM-DK using STM32CubeWB HAL, the Sequencer (UTIL_SEQ), and the HW TimeServer (HW_TS) for periodic tasks. I implemented a repeated LED blink.

  • With CFG_DEBUGGER_SUPPORTED set to 1, the LED toggles on/off every ~5 s as expected.

  • With CFG_DEBUGGER_SUPPORTED set to 0, the LED never blinks, though BLE advertising and characteristic updates continue.

I’ve tuned low-power settings and task scheduling, but the OFF callback (and thus the blink sequence) never runs when CFG_DEBUGGER_SUPPORTED is off. I suspect there is something wrong between Stop mode and the Sequencer/timers, but can’t pinpoint the issue.

/* In Custom_APP_Init(): register tasks & create timers */
UTIL_SEQ_RegTask(1 << CFG_TASK_LEDON,  UTIL_SEQ_RFU, LEDONTask);
UTIL_SEQ_RegTask(1 << CFG_TASK_LEDOFF, UTIL_SEQ_RFU, LEDOFFTask);

HW_TS_Create(CFG_TIM_LEDON_ISR,  &Custom_App_Context.LEDON_TIMER_ID,
             hw_ts_Repeated,   LEDON_TIMER_ISR);
HW_TS_Create(CFG_TIM_LEDOFF_ISR, &Custom_App_Context.LEDOFF_TIMER_ID,
             hw_ts_SingleShot, LEDOFF_TIMER_ISR);

/* Kick off the blink loop on init */
HW_TS_Start(Custom_App_Context.LEDON_TIMER_ID, LEDONTIMER_INTERVAL);

/* Timer ISRs: queue the corresponding tasks */
void LEDON_TIMER_ISR(void)
{
    UTIL_SEQ_SetTask(1 << CFG_TASK_LEDON, CFG_SCH_PRIO_1);
}

void LEDOFF_TIMER_ISR(void)
{
    HW_TS_Stop(Custom_App_Context.LEDOFF_TIMER_ID);
    UTIL_SEQ_SetTask(1 << CFG_TASK_LEDOFF, CFG_SCH_PRIO_1);
}
/* LED on: disable Stop mode, set LED, schedule off */
void LEDONTask(void)
{
    UTIL_LPM_SetStopMode(CFG_LPM_APP_BLE, UTIL_LPM_DISABLE);
    APP_DBG_MSG("LEDONTask");
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
    HW_TS_Start(Custom_App_Context.LEDOFF_TIMER_ID, LEDOFFTIMER_INTERVAL);
}

/* LED off: clear LED, re-enable Stop mode */
void LEDOFFTask(void)
{
    APP_DBG_MSG("LEDOFFTask");
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
    UTIL_LPM_SetStopMode(CFG_LPM_APP_BLE, UTIL_LPM_ENABLE);
}



 

8 REPLIES 8
FilipKremen
ST Employee

Hello,

could you please share the project?

Thank you.

Best regards,

ST support

Make sure you're explicitly enabling the GPIOA clock when you enable / setup the pin.

Perhaps dump the register settings to a console / output, independently of the debugger.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

@FilipKremen wrote:

Hello,

could you please share the project?

Thank you.

Best regards,

ST support


Hi Filip,
Here is the zip file:

FilipKremen
ST Employee

Hello,

did you change anything else? I tried your project, and I can see pin toggling with or without CFG_DEBUGGER_SUPPORTED.

Best regards,

ST support

Hi Filip,

did you enable LPM. I think it has something to do with low power mode. 
When I enable low power mode. The LED doesn’t toggle. 
thanks. 

FilipKremen
ST Employee

Hello,

I noticed you enabled standby mode during initialization. It should be disabled in MX_APPE_Init() function.

Please note that if you want to enter standby mode, the radio must be turned off. Please have a look at this topic here as it can be helpful for your implementation.

Solved: Re: Problem with entering standby mode in STM32WB5... - STMicroelectronics Community

void MX_APPE_Init(void)
{
  System_Init();       /**< System initialization */

  SystemPower_Config(); /**< Configure the system Power Mode */

  HW_TS_Init(hw_ts_InitMode_Full, &hrtc); /**< Initialize the TimerServer */

/* USER CODE BEGIN APPE_Init_1 */
  APPD_Init();

  UTIL_LPM_SetOffMode(1U << CFG_LPM_APP, UTIL_LPM_DISABLE);
/* USER CODE END APPE_Init_1 */
  appe_Tl_Init();	/* Initialize all transport layers */

  /**
   * From now, the application is waiting for the ready event (VS_HCI_C2_Ready)
   * received on the system channel before starting the Stack
   * This system event is received with APPE_SysUserEvtRx()
   */
/* USER CODE BEGIN APPE_Init_2 */

/* USER CODE END APPE_Init_2 */

   return;
}

Best regards,

ST support

Hi Filip,
I updated the code according to your recommendation but the GPIO still doesnt toggle.
I have reuploaded the file again, could you please review.
Thanks

FilipKremen
ST Employee

Hello,

please try to comment this line __HAL_RCC_GPIOA_CLK_DISABLE() in APPD_Init(). This function disables the clock for GPIOA. Let me know if it works on your side, thank you.

Best regards,

ST support