cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Not Working When Using VDD for VBAT on STM32L4

Sujith
Associate II

Hello STM32 Community,

I’m encountering an issue with the RTC on my STM32L4 microcontroller. When I connect VDD to the VBAT pin (without using a battery), the RTC is not functioning. However, if I use a battery for VBAT, the RTC works fine.

Here’s the situation:

  • I’m not using a battery for VBAT, and I’m connecting VDD directly to VBAT.
  • The RTC does not work in this configuration.
  • When I use a battery for VBAT, the RTC works as expected.

My Questions:

  1. Is there an issue with supplying both VDD and VBAT at the same time, without using a battery for VBAT?
  2. Why does the RTC stop working when VDD is connected to VBAT directly, but works fine with a battery?
  3. What is the correct setup for powering the RTC when VBAT is connected to VDD instead of using a battery?

Any insights or recommendations for solving this would be greatly appreciated!

Thank you for your help!

14 REPLIES 14

For test purpose, you can add one resister (220Ohm? depends your power consume) between Vbat and Vdd ,add one capacitor 100 uF , provide power to Vbat. This will emulate Vbat and Vdd delay.

It may give you idea.

1. Internal without Battery:

  • BDCR: 0x0000820B
    • Differences from default:
      • LSEON (bit 0) = 1 (LSE enabled).
      • LSERDY (bit 1) = 1 (LSE is ready).
      • LSEDRV (bits 3-4) = 01 (Medium-low drive strength).
      • RTCSEL (bits 8-9) = 01 (RTC clock source is LSE).
      • RTCEN (bit 15) = 1 (RTC is enabled).
    • RTC_TR: 0x00000033: Time shows 00:00:33.

Comparison with Default:

  • LSE is enabled, and the RTC is running properly with the LSE clock source.
  • RTC has incremented from the default time of 00:00:00 to 00:00:33.

2. Internal with Battery:

  • BDCR: 0x0000820B (Same as previous).
  • RTC_TR: 0x00000115: Time shows 00:01:15.

Comparison with Default:

  • Similar to the previous case, but the time has incremented to 00:01:15.
  • The battery ensures that the RTC keeps counting even if the main power is lost, unlike the default state where the RTC is disabled.

3. External with Coin Battery:

  • BDCR: 0x0000810B
    • Differences from default:
      • LSEON (bit 0) = 1 (LSE enabled).
      • LSERDY (bit 1) = 1 (LSE is ready).
      • LSEDRV (bits 3-4) = 00 (Low drive strength).
      • RTCSEL (bits 8-9) = 01 (RTC clock source is LSE).
      • RTCEN (bit 15) = 1 (RTC is enabled).
    • RTC_TR: 0x00000006: Time shows 00:00:06.

Comparison with Default:

  • LSE is enabled, and the RTC is counting up from 00:00:06.
  • The coin battery allows the RTC to keep running without VDD.
  • By default, the RTC would be disabled and not operational.

4. External without Battery (Drive Medium-Low):

  • BDCR: 0x00008100
    • Differences from default:
      • LSEON (bit 0) = 0 (LSE not enabled).
      • LSERDY (bit 1) = 0 (LSE is not ready).
      • LSEDRV (bits 3-4) = 01 (Medium-low drive strength set).
      • RTCSEL (bits 8-9) = 00 (No clock source for the RTC).
      • RTCEN (bit 15) = 0 (RTC clock is disabled).
    • RTC_TR: 0x00000000: Time shows 00:00:00 (default).

Comparison with Default:

  • The RTC is effectively disabled, similar to the default state.
  • Without a valid clock source, the RTC does not function, and time remains at 00:00:00.

5. External without Battery (Drive High):

  • BDCR: 0x00008100 (Same as the previous case).
  • RTC_TR: 0x00000000 (Same as default).

You find the BDCR bit 8 need change to "1" , could you write to this bit?

This time the register is locked, you need follow reference manual page 1038 , enable this register first.

 

@SofLit, @STTwo-32

For this case, reset cause different, any suggestion from ST?

Sujith
Associate II

Issue Solved - RTC LSE Oscillator Configuration

Hi everyone,

The issue has been resolved! I made a few configuration changes:

  1. First, I disabled the LSI.
  2. Then, I set the LSE drive to high.
  3. Finally, I enabled the LSE.

After these adjustments, the oscillator is now working as expected.

Thank you for your support!

Best regards,
A. Sujith