cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB5mmdk standby mode

samuel_l
Associate II

In my ble application(BLE peripheral) code i need to enter standby mode(BLE can be disabled in stand by mode), after 20 sec by RTC wake up i need to enable the BLE again, start advertising and do some ADC reading.

 

Is there any particular example code is available to enter the stm32wb series in standby mode in a ble application?

If i use LPM manager by the STM cube ide is it possible to enter standby mode and stay there for 20 sec?

8 REPLIES 8
STTwo-32
ST Employee

Hello @samuel_l and welcome to the ST Community.

I Think the GitHub example stm32-hotspot/STM32WB-BLE-standby: Standby is a low power mode available on STM32 MCUs, in this repository we share a STM32WB BLE code example on a standby use case can provide the best guidance for you to implement the Standby on the same BLE context. To go to Standby mode. the BLE should stopped before entering Standby mode.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

samuel_l
Associate II

Yes i tried to modify my application as per the sample you provided.

but after the boot up i always end up in ADC init error.

 

  /* Verification that ADC voltage regulator is correctly enabled, whether    */
  /* or not ADC is coming from state reset (if any potential problem of       */
  /* clocking, voltage regulator would not be enabled).                       */
  if (LL_ADC_IsInternalRegulatorEnabled(hadc->Instance) == 0UL)
  {
    /* Update ADC state machine to error */
    SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_INTERNAL);

    /* Set ADC error code to ADC peripheral internal error */
    SET_BIT(hadc->ErrorCode, HAL_ADC_ERROR_INTERNAL);

    tmp_hal_status = HAL_ERROR;
  }

 

 and this is my standby entering code 

 

static void Go_standby()
{
// TODO: check the connection status//
  aci_gap_terminate( GetBleConnectionHandle(), 0x05 );

  HAL_Delay(100);

  /* Check if the system was resumed from Standby mode */
  if(LL_PWR_IsActiveFlag_C1SB() != 0)
  {
    /* Clear Standby flag */
    LL_PWR_ClearFlag_C1STOP_C1STB();
  }

  /* Disable all used wakeup sources */
  HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);

  /* Clear all wake up Flag */
  LL_PWR_ClearFlag_WU();

  /* Enable pull up on wakeup pin PC5 */ // changed to RTC
  HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0xFFFF, RTC_WAKEUPCLOCK_RTCCLK_DIV16);

  /* As default User push-button (SW1) state is high level, need to clear all wake up Flag again */// changed to RTC
  LL_PWR_ClearFlag_WU();

  /* Allow low power manager to go into standby */
  UTIL_LPM_SetOffMode(1 << CFG_LPM_APP_BLE, UTIL_LPM_ENABLE);
}

 

am i missing something ?

 

What i suggest you is to use the example i've provided as it is and try to add the ADC task there.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

samuel_l
Associate II

The issue is the sample provided is for STM32Wb55 nucleo, My board is STM32WB5MMDK.

That's why i modified as per the sample code.

 

Then, you have to create a new project for your board and repeat the same procedure but adapting it to the specificities of the DK board (that should not be a big difference). Then, if the BLE standby part works fine, you can enable the ADC, Set the function of data recuperation and create a task for it.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

samuel_l
Associate II

I can create a new project that's fine.

But how can i adapt these standby mode in that?

That should be easy. I don't think it will take a lot of changes (it may even work as it is) since they are both based STM32WB55 (1M) MCUs. The only modification should be on the program parts related to the HW Board.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

samuel_l
Associate II

I created new P2P server sample using stm cube ide and manually copied wanted changes in my sample but it is not building getting some build errors. I think both have some small difference in the wpan side.