cancel
Showing results for 
Search instead for 
Did you mean: 

How to check Stop mode current consumption on Nucleo-L073 board

PSaga.1
Associate II

Hello,

I'm working on a low-power application using the STM32L073 microcontroller and aiming to achieve a current consumption of around 3.5 µA in Stop mode. Here are the steps I've followed so far:

  1. Power Connections: I'm powering the microcontroller directly via VDD with a voltage of 3.3V.

  2. Nucleo Board Configuration: I have removed the JP5 connection on my Nucleo-L073 board along with the CN2 jumper connections.

Despite my efforts, the current consumption I'm observing ranges between 260 µA to 280 µA, which is significantly higher than my target.

Here are the crucial parts of the code I've used to measure the current consumption:

 

 

#include "main.h"

// Function prototypes
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
void HW_EnterStopMode(void);
void Error_Handler(void); // Function prototype for Error_Handler

int main(void) {
    HAL_Init();
    SystemClock_Config();
    MX_GPIO_Init();

    // Main loop
    while (1) {
        // Enter Stop mode
        HW_EnterStopMode();
    }
}

void HW_EnterStopMode(void) {
    // Suspend SysTick to prevent waking up from interrupts
    HAL_SuspendTick();

    // Clear the wake-up flag
    __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);

    // Enter Stop mode with low power regulator ON and wait for interrupt
    HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

    // After waking up, reconfigure the system clock
    SystemClock_Config();

    // Resume SysTick
    HAL_ResumeTick();
}

static void MX_GPIO_Init(void) {
    GPIO_InitTypeDef GPIO_InitStruct = {0};

    // Enable GPIO clock
    __HAL_RCC_GPIOB_CLK_ENABLE();

    // Configure GPIO pin for external interrupt (e.g., button)
    GPIO_InitStruct.Pin = GPIO_PIN_1; // Change as needed for your setup
    GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

    // Enable and set EXTI line 0 and 1 Interrupt to the lowest priority
    HAL_NVIC_SetPriority(EXTI0_1_IRQn, 2, 0);
    HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
}

// Interrupt handler for external interrupt
void EXTI0_1_IRQHandler(void) {
    HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1); // Clear the interrupt flag
}

void SystemClock_Config(void) {
    // Set the system clock to use MSI or HSI at a low frequency (e.g., 100 kHz)
    RCC_OscInitTypeDef RCC_OscInitStruct = {0};

    RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
    RCC_OscInitStruct.MSIState = RCC_MSI_ON;
    RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6; // 100 kHz
    RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;

    if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
        Error_Handler(); // Call Error_Handler on failure
    }

    RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

    RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1;
    RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
    RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

    if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK) {
        Error_Handler(); // Call Error_Handler on failure
    }
}

// Error handler function definition
void Error_Handler(void) {
    /* USER CODE BEGIN Error_Handler_Debug */

    // User can add their own implementation to report the HAL error return state.

    __disable_irq(); // Disable all interrupts

    while (1) {
        // Stay in this loop if an error occurs.
        // You can add a mechanism to blink an LED or send a message here.
    }

    /* USER CODE END Error_Handler_Debug */
}

 

 

Am I missing something in my setup or code? Any insights on how to achieve single-digit µA consumption for my application would be greatly appreciated. Thank you!

 

Hope that helps! Do you want me to assist further on optimizing your code or setup?

2 REPLIES 2

You need to look very carefully at the schematics to identify all possible paths for current leakage.

eg, CN2 disconnects the SWD lines from the ST-Link - but not the reset line.

There may be a connection to the ST-Link for measuring the target voltage.

Probably the easiest way with this Nucleo board is to break off the ST-Link part completely:

https://community.st.com/t5/stm32-mcus-boards-and-hardware/leakage-current-potentially-via-stlink-pins-on-demo-board/m-p/693585/highlight/true#M20109

 

Adventures in low-power measurement with ST boards:

https://community.st.com/t5/stm32-mcus-wireless/excess-current-consumption-running-b-l072z-lrwan1-from-battery/td-p/322961

 

 

PSaga.1
Associate II

Hello Andrew,

I have looked into the schematics and observed USART, MCO, NRST, SWO pins connected over solder bridges to the ST Link where CN2 separates out the required programming pins. So I take off the SBs then you think I will be able to achieve the required current consumption? Thanks for the support.