2024-02-14 08:23 AM
I'm attempting to enable the Stop mode on the STM32L4R5ZIP, but it appears to significantly deviate from the specifications outlined in the datasheet, exhibiting a higher current consumption ranging from 7 to 9 mA in both sleep and stop modes.
Even after setting all free pins to default mode, deactivating all GPIOs, the power consumption remains consistent. I have experimented with both FreeRTOS and a non-FreeRTOS project, yet I consistently observe a 7mA current consumption in STOP Low-Power modes.
In the FreeRTOS project, I implemented tickless mode with the following code snippet:
2024-02-15 09:23 AM
@waclawek.jan wrote:It may be *one* of the explanation - others brought up valid points, too.
It explains the current being in the many-mA range.
I don't think the other things would explain that much excess ?
2024-02-15 09:27 AM
@SD0509 wrote:I removed the jumper JP5 (labelled IDD) on the board and connected a multimeter in series to measure the MCU consumption.
Remember that's still going to measure leakage to other things on the board - in particular, the ST-Link.
There will be directions in the User Manual on other links that will need to be broken to minimise the "stray" currents.
You will also need to check the schematics carefully - sometimes the UM text does not tell the whole story...
☹️
(but these should all be on the order of uA - shouldn't account for 7mA!)
2024-02-15 10:08 AM
void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
/* Called by the kernel before it places the MCU into a sleep mode because
configPRE_SLEEP_PROCESSING() is #defined to PreSleepProcessing().
NOTE: Additional actions can be taken here to get the power consumption
even lower. For example, peripherals can be turned off here, and then back
on again in the post sleep processing function. For maximum power saving
ensure all unused pins are in their lowest power state. */
HAL_DBGMCU_EnableDBGStopMode();
//__disable_irq();
LP_GPIO_Init();
HAL_SuspendTick();
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x500B, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
//STOP2 MODE
HAL_PWREx_EnterSTOP2Mode(PWR_SLEEPENTRY_WFI);
}
void PostSleepProcessing(uint32_t ulExpectedIdleTime)
{
/* Called by the kernel when the MCU exits a sleep mode because
configPOST_SLEEP_PROCESSING is #defined to PostSleepProcessing(). */
/* WAKE UP WITH RTC */
//HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
MX_GPIO_Init();
//__enable_irq();
//
/* resume systicks */
HAL_ResumeTick();
SystemClock_Config();
}
After configuring pins to Analog mode in LP_GPIO_Init function and adding HAL_DBGMCU_EnableDBGStopMode the power consumption dropped to 0.4mA.
2024-02-20 05:51 AM
I'm not sure how to do it. Could you provide me with some insight?
2024-02-20 06:20 AM
I meant:
- disconnect debugger
- remove power
- connect power
JW
2024-02-21 01:07 AM
Thank you all ! I appreciate all your suggestions. The consumption has significantly decreased frome 7mA to 250uA.
But I'm still puzzled by this value that differs from what is indicated in the datasheet. Do you notice anything else that might be causing this issue?
Here's my clock configuration:
and this is my code snippet:
void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
/* Called by the kernel before it places the MCU into a sleep mode because
configPRE_SLEEP_PROCESSING() is #defined to PreSleepProcessing().
NOTE: Additional actions can be taken here to get the power consumption
even lower. For example, peripherals can be turned off here, and then back
on again in the post sleep processing function. For maximum power saving
ensure all unused pins are in their lowest power state. */
HAL_DBGMCU_DisableDBGStopMode();
LP_GPIO_Init();
HAL_SuspendTick();
HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x500B, RTC_WAKEUPCLOCK_RTCCLK_DIV16);
//STOP2 MODE
HAL_PWREx_EnterSTOP2Mode(PWR_SLEEPENTRY_WFI);
}
void PostSleepProcessing(uint32_t ulExpectedIdleTime)
{
/* Called by the kernel when the MCU exits a sleep mode because
configPOST_SLEEP_PROCESSING is #defined to PostSleepProcessing(). */
/* WAKE UP WITH RTC */
HAL_RTCEx_DeactivateWakeUpTimer(&hrtc);
MX_GPIO_Init();
HAL_ResumeTick();
SystemClock_Config();
}
void LP_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOE_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOF_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
HAL_PWREx_EnableVddIO2();
/*Configure GPIO pins : PE2 PE3 PE4 PE5
PE6 PE7 PE8 PE9
PE10 PE11 PE12 PE13
PE14 PE15 PE0 PE1 */
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13
|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : PC13 PC14 PC15 PC0
PC1 PC2 PC3 PC4
PC5 PC6 PC7 PC8
PC9 PC10 PC11 PC12 */
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0
|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4
|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8
|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
/*Configure GPIO pins : PF0 PF1 PF2 PF3
PF4 PF5 PF6 PF7
PF8 PF9 PF10 PF11
PF12 PF13 PF14 PF15 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
/*Configure GPIO pins : PH0 PH1 PH3 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
/*Configure GPIO pins : PA0 PA1 PA2 PA3
PA4 PA5 PA6 PA7
PA8 PA9 PA10 PA11
PA12 PA15 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|GPIO_PIN_12|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PB0 PB1 PB2 PB10
PB12 PB13 PB14 PB15
PB3 PB4 PB5 PB6
PB7 PB8 PB9 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6
|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : PG0 PG1 PG2 PG3
PG4 PG5 PG6 PG7
PG8 PG9 PG10 PG11
PG12 PG13 PG14 */
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
/*Configure GPIO pins : PD8 PD9 PD10 PD11
PD12 PD13 PD14 PD15
PD0 PD1 PD2 PD3
PD4 PD5 PD6 PD7 */
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15
|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
__HAL_RCC_GPIOE_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOF_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
//__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOG_CLK_DISABLE();
__HAL_RCC_GPIOD_CLK_DISABLE();
}
2024-02-21 01:16 AM
@SD0509 wrote:I'm still puzzled by this value that differs from what is indicated in the datasheet.
Again, the datasheet covers just the chip itself - it cannot take anything outside the chip into account.
It also knows nothing of your application.
@SD0509 wrote:anything else that might be causing this issue?
2024-02-21 01:40 AM - edited 2024-02-21 01:40 AM
Another thought:
@SD0509 wrote:
NOTE: Additional actions can be taken here to get the power consumption
even lower. For example, peripherals can be turned off here, and then back
on again in the post sleep processing function. For maximum power saving
ensure all unused pins are in their lowest power state. */
@SD0509 wrote:Do you notice anything else that might be causing this issue?
You've done the bit about "ensure all unused pins are in their lowest power state", but I don't see you turning off any peripherals...?
🤔
2024-02-21 08:34 AM
At the project's creation, I didn't initialize the pins to their default mode. Moreover, I've disabled all AHB1, AHB2, APB1, and APB2 peripheral clocks, yet the power consumption remains unchanged.
2024-02-21 08:43 AM
Back to this post:
are you sure you've isolated everything to be sure that what you're measuring in just the STM32L4R5 and nothing else?