2025-02-06 02:49 AM - last edited on 2025-02-06 03:10 AM by Andrew Neil
I am starting a new project with the STM32L432. I need the RTC, but I don't understand how to manage the backup battery. This microcontroller doesn't have a dedicated VBAT pin. From what I understand, both the main power supply and the backup battery should be connected to the single power supply pin, and somehow the microcontroller should enter STANDBY mode when it detects that the main power supply is missing and is running on the backup battery to consume as little power as possible. Is that correct? But how does the microcontroller know which power source is supplying it, and how does it exit STANDBY mode when the main power supply returns? Is there a code and an example circuit diagram? Thank you
2025-02-06 02:52 AM - edited 2025-02-06 03:09 AM
@LMore.2 wrote:I am starting a new project with the STM32L432. I need the RTC, but I don't understand how to manage the backup battery.
That was answered here:
@LMore.2 wrote:This microcontroller doesn't have a dedicated VBAT pin. From what I understand, both the main power supply and the backup battery should be connected to the single power supply pin,
Correct - as stated in @TDK's solution above
@LMore.2 wrote:But how does the microcontroller know which power source is supplying it,
That will depend entirely on your power supply design.
You have to design your power supply so that it can switch between "main" and "backup" power sources, and give a signal to the STM32 indicating which one is currently in use.
There are chips which can do this, or you can make a discrete design.
PS:
Here's an example
The diodes will "choose" between the Main & Backup power.
The 'Power Sense' input to the STM32 allows it to "see" when Main power is available - if the Main power is not available, it can conclude that it must be running on Backup power.
Note that this has nothing really to do with the STM32; this is general to anything that has Main & Backup power - it's a power supply design issue, rather than an STM32 issue.
"Power Path" would be a good search term ...
2025-02-06 03:38 AM
Hi Andrew,
something like this one?
PB0 (vbus_detect) report information when 5V is present or missing. If missing power from USB, MCU go in STANDBY, when power return MCU exit from sleep on 'PIN change'. Is it correct?. Any better schematic solution? Which chip can do this? Thanks
2025-02-06 03:45 AM - edited 2025-02-06 04:19 AM
When the USB power is removed, that will apply battery power to the output of the U7 regulator - which may not be a good idea ...
What kind of battery is it? Does it need charging?
PS:
Here's an example of an IC power-path controller without battery charging:
https://www.analog.com/en/products/ltc4412.html
Adding discrete power-path control to a charger IC:
https://ww1.microchip.com/downloads/en/appnotes/01149c.pdf
Some charger ICs which include power-path control: