cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55 program was stuck if both BLE and ADC is activated

ZZou.1
Associate

I have an STM32WB55 board. I used the CUBEMX to generate a template that both activates the internal temperature sensor and BLE module.

However, if I ran the program generated, it will be blocked in the "hw_timeserver.c" at line 566, which is:

while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(phrtc, RTC_FLAG_WUTWF) == RESET)

If I turn the ADC off, the program will start properly, and I am able to scan and connect. the problem seems relative to the clock configuration, but I have no idea how to debug it.

I attached my CUBEMX setting file. Can anyone helps me find the problem?

6 REPLIES 6
Sara BEN HADJ YAHYA
ST Employee

Hello,

Could you please provide us with the software's versions that you are using ( STM32CubeMX, Firmware, IDE..)

Best Regards,

Sara

I use CubeIde 1.7, the firmware version is STM32Cube_FW_WB_V1.12.1

MDiep.1
Associate II

I do not know if this is relevant to you @ZZou.1​ but I discovered that using the latest versions of STM32CubeIDE and STM32Cube_FW_WB_V1.12.1 the timeserver does not get initialized with the RTC but during the call to MX_APPE_Init() which can cause a wakeup interrupt to be triggered and thus the RTC_WKUp_IRQ to be executed before the timeserver is initialized. This cause it to hang at the line you specified.

My quick fix is to initialize the timeserver with the RTC:

[file main.c, function MX_RTC_Init(); the exact file may vary depending on your code generation settings]

  /* USER CODE BEGIN RTC_Init 2 */
  HW_TS_Init(hw_ts_InitMode_Full, &hrtc);
  /* USER CODE END RTC_Init 2 */

This ensure that when the first RTC WKUp interrupt is executed it will run correctly as the timeserver will be initialized.

I am not sure this is the best place to put this code but it does seems to do the trick. Maybe iy you have RTC WakeUp interrupts very frequently you might have to put this code at another place ?

Also, do not forget to remove the HW_TS_Init() function call from the MX_APPE_Init() function. You will have to remove it after every new code generation.

I also add ADC on temperature channel in project my_p2p_server4_ADC. Sometimes client doesn't see server. I pause debagger and see

"hw_timeserver.c" at line 411 (not 566 like @ZZou.1​ :(

/**

    * Wait for the flag to be back to 0 when the wakeup timer is enabled

    */

   while(__HAL_RTC_WAKEUPTIMER_GET_FLAG(phrtc, RTC_FLAG_WUTWF) == SET);

CubeIde 1.7, the firmware version is STM32Cube_FW_WB_V1.12.1

PCB is MB1355C

Without ADC temperature channel works without this problem.

 0693W00000GWHh5QAH.png0693W00000GWHhFQAX.png

MDiep.1
Associate II

If anybody finds this post again and wants an answer, the bug might be related to the issue I opened on the github repository for STM32CubeWB. Several fixes are proposed. https://github.com/STMicroelectronics/STM32CubeWB/issues/52

Remy ISSALYS
ST Employee

Hello,

I have additional information, see my answer on this post:

https://community.st.com/s/question/0D53W00001K2koYSAR/hwtimerserver-hangs-on-stm32wb-w-ble?t=1645623930307

Best Regards