Page 1 of 1

Clock frequency change

Posted: Tue Sep 01, 2020 5:00 pm
by mebab
I know that my Nucleo L476 is working with the maximum frequency (80 MHz) and consumes about 60 mA. To reduce the power consumption, I want to try reducing the frequency from 80MHz to for example 32 MHz with Arduino IDE.
I know that there is a file (variant.cpp) that includes all the information regarding to clocks which is a mirror of what Stm32CubeMX presents for clock configuration. A part of this file represents the following:

Code: Select all

/**
  * @brief  System Clock Configuration
  *         The system Clock is configured as follows :
  *            System Clock source            = PLL (MSI)
  *            SYSCLK(Hz)                     = 80000000
  *            HCLK(Hz)                       = 80000000
  *            AHB Prescaler                  = 1
  *            APB1 Prescaler                 = 1
  *            APB2 Prescaler                 = 1
  *            MSI Frequency(Hz)              = 4000000
  *            PLL_M                          = 1
  *            PLL_N                          = 40
  *            PLL_R                          = 2
  *            PLL_P                          = 7
  *            PLL_Q                          = 4
  *            Flash Latency(WS)              = 4
  * @param  None
  * @retval None
  */
Which parameter should be changed?

Re: Clock frequency change

Posted: Tue Sep 01, 2020 5:05 pm
by fpiSTM
Simply use cube MX to play with the clock config then generate the code. Note that you can redefine this function at sketch level as it is weak. Add extern "C" before the function.

Re: Clock frequency change

Posted: Tue Sep 01, 2020 8:05 pm
by mebab
Thanks for your help fpiSTM!
I successfully applied the frequency change from 80 to 32 MHz. However, I just got about 4 mA savings in my application hardware! I am going to find out better solutions to save more power.

Re: Clock frequency change

Posted: Tue Sep 01, 2020 9:53 pm
by fpiSTM
Why not use the low power library?

Re: Clock frequency change

Posted: Wed Sep 02, 2020 4:29 am
by mebab
Actually I have already applied the sleep mode. However, it doesn't make a huge difference in my application. I tried to use deep sleep mode but since I need my SRAM to be alive, the normal operation stopped. Then I have to find out other solutions...

Re: Clock frequency change

Posted: Sat Sep 05, 2020 2:15 am
by .rpv
Hi, 60mA seems quite a bit for a normal STM32 mcu, for a L (low power/consumption) version seems too much, maybe the problem it's on something else.

The datasheet for the STM32L476 mcu says that the power consumption it's 100uA/Mhz, that's 8mA at 80MHz. Also, the nucleo boards I think that includes an stlink, so will be at least 20mA just for the stlink. Maybe that's where the power consuption is.

Re: Clock frequency change

Posted: Sat Sep 05, 2020 9:14 am
by GonzoG
As .rpv wrote, this 60mA current draw has to come from something else than MCU.
I have F401 anf F411 black pills and they draw about 20mA.
And some F103 Bluepills which draw about 30mA.

Re: Clock frequency change

Posted: Mon Sep 07, 2020 8:17 pm
by mebab
Sorry for my late reply! As you mentioned, the ST-link consumes a part of 60 mA. In addition, there are two LEDs (LD1) which is flashing on the ST-Link side when Nucleo is powered from an external source and the other (LD3) representing Power connected to the board. I have other connected shields, an SD memory card reader + LoRa. The system works full-load with 80 MHz. The supplied external voltage is 7.0 Volts. For current measurement, I use a 0.5-ohm resistor. The following figure represents the measured voltage to be divided into 0.5. Those spikes represent packet transmission by LoRa (to be 93 mA according to datasheet) and 12 mA for SD card r/w.
Image
Power test (Voltage across a 0.5-ohm serial resistor) - including all peripherals
Power test (Voltage across a 0.5-ohm serial resistor) - including all peripherals
6_All_Different Scale.jpg (33.47 KiB) Viewed 9101 times
The following (time scale is 500 ms) represents another power test for a single Nucleo connected to an external power supply without any peripheral and no-load condition:
Image
Power test (Voltage across a 0.5-ohm serial resistor) -Only Nucleo
Power test (Voltage across a 0.5-ohm serial resistor) -Only Nucleo
1_Only STM32.jpg (32.19 KiB) Viewed 9102 times