RTC on STM32F407 freezes on power down

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderators: barthess, RoccoMarco

joaquin
Posts: 38
Joined: Sat Jan 22, 2011 8:44 pm
Has thanked: 1 time
Been thanked: 3 times

RTC on STM32F407 freezes on power down

Postby joaquin » Fri Jun 11, 2021 8:58 pm

I'm strugling with a problem for quite a bit, and I'd be very grateful if ayone could provide me with a hint.
I've a STM32F407 board, it has a 3.3V battery on VBat, the LSE crystal is a 32.768 kHz.
In halconf.h I enabled RTC, and in mcuconf.h I configured it:

Code: Select all

#define STM32_RTCSEL                    STM32_RTCSEL_LSE
#define STM32_RTCPRE_VALUE               8

Also in halconf.h I enabled RTC
The RTC works when the power is on, but on power off it doesn't advance, keeping the old values. I've substitute it with other board, and also disconnected both power and Vbat to force a backup domain reset, without success. In hal_lld.c I see that RCC_BDCR has LSEON, LSERDY, RTCSEL is 01 (LSE), and RTCEN

User avatar
Giovanni
Site Admin
Posts: 13629
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 888 times
Been thanked: 768 times
Contact:

Re: RTC on STM32F407 freezes on power down

Postby Giovanni » Fri Jun 11, 2021 10:13 pm

Hi,

Have you tried to change LSEDRV?

Giovanni

joaquin
Posts: 38
Joined: Sat Jan 22, 2011 8:44 pm
Has thanked: 1 time
Been thanked: 3 times

Re: RTC on STM32F407 freezes on power down

Postby joaquin » Sat Jun 12, 2021 6:38 am

I have discovered that after an hour without power, it loses also the RTC values, so clearly the problem lies on the power supply to the backup domain, and not on the LSE oscillator. Now I have more things to learn.
Thanks Giovani!

rew
Posts: 367
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: RTC on STM32F407 freezes on power down

Postby rew » Sun Jun 13, 2021 7:54 am

If it also loses the values, the backup domain seems completely unpowered. That would also explain why the LSE doesn't run.

Either the chip isn't switching power sources when it should, but IMHO that seems unlikely. The way I remember the datasheet is that it switches automatically and you can't configure it not to. That would leave the power on your actual "VBAT" pin to double check.

UL safety regulations require you to have a resistor and a diode in series between your circuit and the battery. If there is something wrong with that circuit, vbat could in fact be not powered. On the other hand, if you have accidentally put something else on there the voltage can easily drop to unusable levels... So a measurement needs to be taken.... (measure at the pin not at the other end of the trace).

(*) to prevent accidental charging of non-rechargable batteries, and to prevent a sudden discharge causing a fire.

davidli
Posts: 2
Joined: Fri Jun 11, 2021 7:15 am

Re: RTC on STM32F407 freezes on power down

Postby davidli » Thu Jun 17, 2021 7:52 am

I also want to know how to solve this problem, should I try to replace the backup power supply if it does not work? Or is the only option to get a brand new unit?

rew
Posts: 367
Joined: Sat Jul 19, 2014 12:59 pm
Has thanked: 2 times
Been thanked: 13 times

Re: RTC on STM32F407 freezes on power down

Postby rew » Thu Jun 17, 2021 3:14 pm

I don't understand what you're trying to say.

The backup power is normally a battery. It is way more likely that "something" is wrong on your PCB or software than that the chip is not switching to backup power as it should. You can test another chip to convince yourself, but I'm betting it shows the same behavior. If you built the board yourself, soldering errors are also an option. So, debugging means double checking the voltages at the pins.


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 6 guests