Clock frequency change

Development environment specific, Arduino, Eclipse, VS2013, Em::Blocks etc
Post Reply
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Clock frequency change

Post 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?
by fpiSTM » Tue Sep 01, 2020 5:05 pm
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.
Go to full post
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Clock frequency change

Post 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.
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Clock frequency change

Post 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.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: Clock frequency change

Post by fpiSTM »

Why not use the low power library?
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Clock frequency change

Post 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...
.rpv
Posts: 43
Joined: Wed Dec 18, 2019 10:19 pm

Re: Clock frequency change

Post 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.
GonzoG
Posts: 403
Joined: Wed Jan 15, 2020 11:30 am
Answers: 26
Location: Prudnik, Poland

Re: Clock frequency change

Post 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.
mebab
Posts: 115
Joined: Mon Aug 24, 2020 12:42 pm
Answers: 4

Re: Clock frequency change

Post 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 9018 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 9019 times
Post Reply

Return to “IDE's”