cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L031F4 power consumption too high

Alvanicus
Associate

Hello,

I have a project that uses the STM32L031F4. I need the board to have the current under 1mA whilst running. However, I cannot get the current this low, even according to the data sheet, the max current consumption for Vcore=1.2V should be 0.2mA.

To test the minimum current for the board, I have set up the following:

  • Using the MSI oscillator as the system clock.
  • Configured MSI for range1 (131.072kHz).
  • Set Vcore to 1.2V
  • Set SLEEP_PD in FLASH_ACR register to switch of Flash while asleep.
  • LPRUN and LPSDSR bits set in PWR_CR
  • Set SLEEPDEEP bit in system control register (to stop the MCU)
  •  PDDS bit=0 and WUF bit =0 in PWR_CR.
  • Timer2 clock is enabled.

Is there anything I am missing on how to reduce the current consumption?

Regards

Alvin

4 REPLIES 4
MM..1
Chief II

Check you dont enable debug in lowpower modes or turn power after flash loaded completely off and measure turn on without debuger stlink connected.

Andrew Neil
Evangelist III

@Alvanicus wrote:

Is there anything I am missing


You haven't said anything about what else is on the board besides the STM32L031F4.

post your schematic, and show your code:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

 

Alvanicus
Associate

Thanks for your reply.

The code for the project is in Pascal. I have not implemented any of the features for the project yet. I just wanted to see the minimum current consumption of the board, so I could then work with that. Even though I have initialized the timer, I have not implemented the interrupt yet.

begin
  { Initialise MCU port pins }
  InitGPIO();
  
  { Change MSI clock range to range 1 - 131.072kHz }
  RCC_ICSCR.MSIRANGE0 := 1;
  RCC_ICSCR.MSIRANGE1 := 0;
  RCC_ICSCR.MSIRANGE2 := 0;
  
  { Set low power mode }
  PWR_CR.LPDS := 1;
  PWR_CR.LPRUN := 1;

  { Disable Flash while asleep }
  FLASH_ACR.SLEEP_PD := 1;
  
  { Enable STOP }
  SCB_CCR.SLEEPDEEP := 1;
  PWR_CR := 0;
  PWR_CR.WUF := 0;
  RCC_CFGR.STOPWUCK := 0;

  { Initialise sleep timer }
  InitTimer();
  
  { Turn LEDs off }
  RedLed := 1;
  BlueLed := 1;
  GreenLed := 1;
  
  while (true) do
  begin
    asm
      wfi;
    end;
  end;
end;

procedure InitGPIO( );
begin
  GPIO_Analog_Input  ( @GPIOA_BASE, _GPIO_PINMASK_0 ); // Line monitor ADC.
  GPIO_Analog_Input  ( @GPIOA_BASE, _GPIO_PINMASK_1 ); // Line state ADC.
  GPIO_Digital_Output( @GPIOA_BASE, _GPIO_PINMASK_2 ); // Call Line pin.
  GPIO_Digital_Output( @GPIOA_BASE, _GPIO_PINMASK_3 ); // Blue LED
  GPIO_Digital_Output( @GPIOA_BASE, _GPIO_PINMASK_4 ); // Red LED
  GPIO_Digital_Output( @GPIOA_BASE, _GPIO_PINMASK_5 ); // Green LED
  GPIO_Digital_Output( @GPIOA_BASE, _GPIO_PINMASK_6 ); // EOL
  
  GPIO_Digital_Output( @GPIOA_BASE, _GPIO_PINMASK_9 );  // TX
  GPIO_Digital_Input ( @GPIOA_BASE, _GPIO_PINMASK_10 ); //RX

  { Monitoring enable switch }
  GPIO_Config( @GPIOB_BASE, _GPIO_PINMASK_1, _GPIO_CFG_DIGITAL_INPUT or _GPIO_CFG_PULL_UP );

  { Status LED Colour when active }
  GPIO_Config( @GPIOC_BASE, _GPIO_PINMASK_14, _GPIO_CFG_DIGITAL_INPUT or _GPIO_CFG_PULL_UP );
  
  { Normally open/closed switch }
  GPIO_Config( @GPIOC_BASE, _GPIO_PINMASK_15, _GPIO_CFG_DIGITAL_INPUT or _GPIO_CFG_PULL_UP );
end;

procedure InitTimer( );
begin
  { Enable clock power }
  RCC_APB1ENR.TIM2EN := 1;

  { Disable timer before configuring it }
  TIM2_CR1.CEN := 0;

  { Clear the update event flags }
  TIM2_SR := 0;

  { Set timer }
  TIM2_PSC := 499;
  TIM2_ARR := 999;

  NVIC_IntEnable(IVT_INT_TIM2);  // Enable timer interrupt
  TIM2_DIER.UIE := 1;            // Update interrupt enable
  TIM2_CR1.CEN := 1;             // Enable timer
end;

 Even th 

On normal physics law is irelevant how speed you do job, energy will constant. Then on MCU is better balance short high speed jobs with long total stop mode, instead slow continuos exec...

And from your code you set STOP mode but first wake end it and newer start back.