Skip to main content
Associate III
June 12, 2024
Solved

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

  • June 12, 2024
  • 1 reply
  • 2170 views

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!

Best answer by Sarra.S

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!

1 reply

ST Employee
June 12, 2024

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.
ExeuAuthor
Associate III
June 12, 2024

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?

Sarra.SBest answer
ST Employee
June 13, 2024

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.