Skip to main content
ZZou.1
Associate
October 3, 2021
Question

STM32WB55 program was stuck if both BLE and ADC is activated

  • October 3, 2021
  • 4 replies
  • 2308 views

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?

This topic has been closed for replies.

4 replies

Sara BEN HADJ YAHYA
Technical Moderator
October 26, 2021

Hello,

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

Best Regards,

Sara

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question.
ZZou.1
ZZou.1Author
Associate
October 27, 2021

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

MDiep.1
Associate II
October 29, 2021

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.

dungeonlords789
Associate III
November 3, 2021

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
February 4, 2022

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
Technical Moderator
February 23, 2022

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