Skip to main content
Htzuh
Associate II
June 18, 2019
Solved

How to enter stop2 mode in stm32wb, when the Ble stack opened?

  • June 18, 2019
  • 11 replies
  • 4009 views

According to the subject, I found I can't enter to the stop2 mode ,when i run the ble stack (APPE_Init() ) in p2p_server. I tried to use HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI); behind the aci_gap_set_non_discoverable(); but it wasn't worked . What program i need to add?

Thank you very much.

​

This topic has been closed for replies.
Best answer by Christophe Arnal

Hello,

You should no add any code to enter stop mode 2. I am not sure where you added SCH_Run(0) but wherever this was added, please remove it.

I would suggest to start from the p2p_sever example as it has been delivered without any code change and modify the setting in app_conf.h to have

Set CFG_DEBUGGER_SUPPORTED  to 0

Set CFG_DEBUG_BLE_TRACE   to 0

Set CFG_DEBUG_APP_TRACE   to 0

To make sure the device enter low power mode, you may output the system clock on the MCO ouput and check the signal with either an oscilloscope or a digital analyzer. When the device enters Stop Mode, you should see the clock not toggling anymore in between advertising packets.

You may use HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv) to ouput the system clock on MCO.

Regards.

11 replies

ST Employee
June 20, 2019

Hello,

The only thing to do to make a BLE application running with the best power consumption is to change the default settings in app_conf.h

All BLE applications are keeping the debugger and traces enable to help the user to implement and debug his application

The BLE_HearRate is the only one which is by default configured to provide by default the best power consumption.

You may check the differences between the two app_conf.h files but basically, you need to

Set CFG_DEBUGGER_SUPPORTED  to 0

Set CFG_DEBUG_BLE_TRACE   to 0

Set CFG_DEBUG_APP_TRACE   to 0

Regards.

Htzuh
HtzuhAuthor
Associate II
June 24, 2019

Thank you very much. I Tried to check the BLE_HeartRate example and changed the app_conf.

The program entered the low power mode when Ble tasks ran in SCH_Idle, but i found that

the mcu in stop mode after running ble stack which power consumption is ten times larger than

mcu in stop mode before running ble stack . Is it possible to turn off only the part of BLE?

​

Regards

ST Employee
June 24, 2019

Hello,

The p2p_server application is advertising at startup. It depends which tool you are using to make power measurement.

Between advertising packets, the STM32WB should enter Stop Mode 2. In that case the power consumption is in the range of 2.8uA.

When the device advertises, the Radio is transmitting and the power consumption increases to several mA.

The tool you are using to make power measurement may not be able to make correct power measurement with a power switch from some few uA to few mA.

This is most of the time the case with multimeter and the average power measurement reported is not correct.

Could you please confirm which tool you are using to make power measurement ?

This shield below is providing very accurate power measurements

https://www.st.com/en/evaluation-tools/x-nucleo-lpm01a.html

Regards.

chinmaydixit
Associate III
August 13, 2021

Hello @Christophe Arnal​ ,

As you said, I used Accurate Power Measurement board which is designed by ST itself which you have mentioned in the link, but could not get any results as yo claimed unfortunately. When BLE is advertising, the current consumption is somewhere around 6 to 7 mA. And after the Advertising stops, there is no change in current. When BLE stops advertising I also put CPU1 to standby mode but still there is no change in current. Please Guide me.

Thank you so much.

ST Employee
August 13, 2021

Hello,

I would suggest to just try the heart rate out the package with no modification. It is configured by default to provide correct low power consumption.

This will be a first step to confirm whether your way of measurement is correct or not.

All other examples have the traces and the debugger enabled by default so they will not enter stop mode.

Regards.

Htzuh
HtzuhAuthor
Associate II
June 26, 2019

Thank you.

I want to enter the stop2 mode after device stopping advertising (aci_gap_set_non_discoverable(); ),

so I have followed the example code and added SCH_Run(0) after device stopping advertising in order to enter

he SCH_Idle() and stop2 mode.

​

I use multi-meter to measure the current which was 4.3 mA on JP2 of Nucleo-68 board.

It is a lot different from the spec.

​

I think that the MCU didn't enter the low power mode.

​

Which part do i need to modify?

Regards.

​

​

​

​

Christophe ArnalBest answer
ST Employee
June 26, 2019

Hello,

You should no add any code to enter stop mode 2. I am not sure where you added SCH_Run(0) but wherever this was added, please remove it.

I would suggest to start from the p2p_sever example as it has been delivered without any code change and modify the setting in app_conf.h to have

Set CFG_DEBUGGER_SUPPORTED  to 0

Set CFG_DEBUG_BLE_TRACE   to 0

Set CFG_DEBUG_APP_TRACE   to 0

To make sure the device enter low power mode, you may output the system clock on the MCO ouput and check the signal with either an oscilloscope or a digital analyzer. When the device enters Stop Mode, you should see the clock not toggling anymore in between advertising packets.

You may use HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv) to ouput the system clock on MCO.

Regards.

Htzuh
HtzuhAuthor
Associate II
June 27, 2019

Thanks .

Can program jump out to the Ble scheduler ?

​

I want to close Ble stack and do another application.

​

Then , the mcu will reset the Ble stack and run Ble application.

​

Regards.

ST Employee
June 27, 2019

Hello,

From now I will rename scheduler into sequencer because that's the way it is documented in the AN and how this will be delivered in the coming v1.2.0 release.

The sequencer implements a basic baremetal while() loop where each function that you would like to be called in the background while loop shall be first registered and then triggered with UTIL_SEQ_SetTask().

Based on this, you cannot jump out from the sequencer as this would mean jumping out from the background while loop.

However, as long as the stack is not triggered , it will not be executed so this is matching the behavior you would like to see eg no ble activity and no ble application running in background.

There is no need to close the Ble Stack. As long as there is no BLE activity, the CPU2 Ble subsystem will be in low power and will not burn any power than as if it has never been started.

So, when you do not need anymore BLE, you dont have something specific to be done with the ble stack to enter stop mode. As long as you have no more ble activity ( no scan, no advertize, no connetcion ), the BLE susbystem will burn no power.

If you need to run another application in background, just register it to the sequencer and call UTIL_SEQ_SetTask() each time you need it to be executed once in the background.

Regards.

Htzuh
HtzuhAuthor
Associate II
June 27, 2019

I find that ​I must add LL_AHB2_GRP1_ReleaseReset(); to clear the ouput interrupt ping

before go to stop mode .

Then, the system will go into low power.

Thanks.

ST Employee
June 27, 2019

Hello,

I believe in that case you were entering stop mode ( eg if you monitor the system clock on the MCO, you should see some time that it does not run).

The power consumption was very likely due to a wrong GPIO setting that was driving current.

Calling LL_AHB2_GRP1_ReleaseReset() before entering Stop Mode may not suit your application because this will demux all your peripheral (UART, SPI, etc..) that you may have configured upfront.

I would suggest to identify which IO was driving current and fix it.

Regards.