cancel
Showing results for 
Search instead for 
Did you mean: 

Standby mode - Power peaks when measuring power consumption, a normal thing?

Exeu
Associate II

Hi there,

i am currently working on a BLE Customboard using a STM32WB55.

The current setup allows for a 1 second long BLE Advertising, to transmit sensor data.

After this second the device is going into STANDBY MODE using the tiny_lpm class:

 

// from app_ble.c -> Callback when the HW_TIM has timedout after 1 second.

static void Adv_Mgr(void) {
  aci_gap_set_non_discoverable();
  UTIL_LPM_EnterLowPower();
}

 

In the stm32_lpm_if.c i am doing the following to actually stretch the wakeup time to be several minutes / hours:

 

void PWR_EnterOffMode(void) {
/* USER CODE BEGIN PWR_EnterOffMode_1 */
  HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
  if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, RTC_WAKEUP_COUNTER, RTC_WAKEUPCLOCK_CK_SPRE_16BITS) != HAL_OK) {
    Error_Handler();
  }

..... 
The rest of the function as it is.

 

Overall this seems to work quite nice since i am ending up with a power consumption of 0.6-0.7 uA which is matching with the datasheet.

I wanted to clarify if the spikes you see in the screenshot below are a normal thing?

The device itself is in standby and NOT waking up as expected. The power-consumption is at minimum but if i zoom in the time axis i can see spikes occouring in a regular pattern.

I am not sure if this is normal / or maybe has sth. to do with measuring inconsistencies.

Exeu_0-1718205333249.png

The RTC-Timer itself should be powered through LSI-Clock.

 

void HAL_RTC_MspInit(RTC_HandleTypeDef *hrtc) {
  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
  if (hrtc->Instance == RTC) {
    /* USER CODE BEGIN RTC_MspInit 0 */

    /* USER CODE END RTC_MspInit 0 */

    /** Enable access to the backup domain
    */
    HAL_PWR_EnableBkUpAccess();

    /** Initializes the peripherals clock
    */
    PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
    PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
    if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
      Error_Handler();
    }

    /* Peripheral clock enable */
    __HAL_RCC_RTC_ENABLE();
    __HAL_RCC_RTCAPB_CLK_ENABLE();
    /* RTC interrupt Init */
    HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);
    /* USER CODE BEGIN RTC_MspInit 1 */

    /* USER CODE END RTC_MspInit 1 */
  }
}

 

And:

 

static void MX_RTC_Init(void) {
  /** Initialize RTC Only
  */
  hrtc.Instance = RTC;
  hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
  hrtc.Init.AsynchPrediv = CFG_RTC_ASYNCH_PRESCALER;
  hrtc.Init.SynchPrediv = CFG_RTC_SYNCH_PRESCALER;
  hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
  hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
  hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
  hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
  if (HAL_RTC_Init(&hrtc) != HAL_OK) {
    Error_Handler();
  }

  /** Enable the WakeUp
  */
  if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0, RTC_WAKEUPCLOCK_RTCCLK_DIV16) != HAL_OK) {
    Error_Handler();
  }
}

 

 

Thank you for some feedback!

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Exeu

Yes, these spikes you observe when the device wakes up from standby mode are a normal consequence of waking up after a certain amount of time

Here is why: when the RTC WakeUp Timer expires, it triggers an interrupt that wakes the microcontroller from standby mode. when waking up, it powers up the CPU and possibly other system peripherals, which consumes more power than when the system is in standby mode.

After that, it will re-enter standby mode, and the power consumption will drop back down to the low standby level! 

I hope that's clear!

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.

View solution in original post

6 REPLIES 6
Sarra.S
ST Employee

Hello @Exeu

I am not sure you're addressing the spikes in standby mode that correspond to the WakeUp Timer interval -which is a normal part of the device's operation- the MCU wakes up and executes some code and then returns to standby mode at regular intervals since you're using the RTC WakeUp timer. 

 

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.

Hey @Sarra.S.

Thanks for the answer.

Yes I am addressing those spikes in standby mode. 

I guess this is not avoidable or? My setup does not have any external wakeup.it needs to wakeup after a certain amount of time. So I guess rtc wakeup timer is the only thing working?

Hello @Exeu

Yes, these spikes you observe when the device wakes up from standby mode are a normal consequence of waking up after a certain amount of time

Here is why: when the RTC WakeUp Timer expires, it triggers an interrupt that wakes the microcontroller from standby mode. when waking up, it powers up the CPU and possibly other system peripherals, which consumes more power than when the system is in standby mode.

After that, it will re-enter standby mode, and the power consumption will drop back down to the low standby level! 

I hope that's clear!

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.

Thank you for the info @Sarra.S ,

My device is in standby most of the time, i only need to wake it up after every 10 minutes. Then do some stufff for 0.5 seconds and then go back to standby.

Currently i solved this by using the

HAL_RTCEx_SetWakeUpTimer_IT

 

Would a RTC Alarm change anything regarding those spikes?

I guess not since i think they are both based on RTC but i wanted to clarify this.

Other than that: Is there maybe also another way of waking up the device after a fixed amount of time?

Currently i just can see RTC Alarm or RTC Wakeup (with wakeup counter).

Thank you

I don't think there is a big difference between the 2 approaches, maybe the alarm will offer more flexibility in terms of setting the exact moment of the wake-up! 

another method could be using an LPTIM that can run in low-power modes and wake up the MCU. This could potentially offer a more power-efficient wake-up!

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.

Yes i also thought about a LPTIM, but as per datasheet it seems LPTIM is not available in Standby anymore.

But i think the solution is fine for now 🙂

Thanks