2022-07-04 10:10 PM
Hi. I am working on a battery operated project using STM32L031 microcontroller. I am using 32 MHz clock for normal operation. But if I use same clock in low power mode then it consumes current of about 2.7mA. But for higher battery life, current consumption should be minimum. So I tried running controller at 2MHz and the current consumption was found to be around 350uA in low power mode.
So I was thinking of using 32MHz for normal operation and when entering low power mode, drop that clock frequency to 2 MHz. And when exiting low power mode, clock frequency should be again switched to 32MHz.
My UART (with DMA) is always active since whenever I receive data, I come out of low power mode. My baud rate is 115200 and hence I cant go below 2MHz clock frequency.
So how can I implement this operation of changing clock frequency from low to high and vice versa?
Regards,
noobmaster69
2022-07-05 12:50 AM
Hi @Community member ,
Thank you for sharing your request, first can you provide me more information about your project. ;)
What's low power mode are you referring to ?
The STM32Lx31 supports five low-power modes :
Please refer to the section 3.1 Low-power modes of the datasheet for more details.
Best regards,
A.MVE
2022-07-05 01:16 AM
Hi @Aime ,
Thanks for your reply. I am planning to use Low power Sleep mode. Because in this mode DMA is active which is required for USART. In low power mode, I need only USART active. It wakes up from lwo power mode when I receive data. It ccan also wakeup from Interrupt from a input pin. Also I might need SysTick running because I am using it as a timer to hourly read battry voltage using ADC.
And for the info on my project, it is a battery operated access control system with NFC, Bluetooth functionality.
Regards,
noobmaster69
2022-07-05 01:22 AM
Not familiar with your application but in certain cases you can manipulate the RCC bus dividers to ease the transition from 32MHz to 2MHz. A simple example that requires little programming: configure AHB and APB bus dividers to /16, so your peripherals always run at 2MHz. When you slow down the oscillator, reduce the bus dividers to /1 so the UART continues to function.
Obviously using this method is dependent on how you must configure your other peripherals, but if you shut them down to save power at 2MHz then it's a moot point.
Also, be sure to use SLEEP mode to halt the CPU when idling at 2MHz, waking only when the UART signals end of transmission (TE interrupt, preferable to DMA end). Halting instruction execution saves power in the processor core.
Jack Peacock
2022-07-05 01:36 AM
Thanks for your reply. Much appriciated. Will try to implement what you said.
Regards,
noobmaster69
2022-07-05 02:11 AM
Understand @Community member ,
Please notice that to use Low power Sleep mode you need to :
I recommend to you to have two System_Clock_Config functions one for running at 32MHz and the other for your Low Power Sleep mode.
On the second one you need to configurate your System frequency up to MSI range 1 (e.g 2MHz) and update your MCU voltage to range 2. This function should be call before entering Low power Sleep mode.
When exiting from Low power Sleep mode first call the other System_Clock_Config function to run at 32MHz.
Best regards,
A.MVE
2022-07-05 07:33 AM
For normal battery app is better use RUN MODE optimized speed and STOP MODE while wait for events to run.
2022-07-16 01:06 AM
Also I wanted to know how to disable and enable systick when entering and exiting low power mode.
2022-07-17 11:37 PM
Hi,
Here are my answers.