Skip to main content
Visitor II
October 22, 2024
Solved

RTC Not Working When Using VDD for VBAT on STM32L4

  • October 22, 2024
  • 5 replies
  • 3843 views

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!

    This topic has been closed for replies.
    Best answer by Sujith

    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

    5 replies

    Graduate II
    October 22, 2024

    Go in the debugger and check RTC registers and maybe RCC settings related to the RTC in both situations. I have used L4 RTC in both situation w/o problems as you see.

    Super User
    October 22, 2024

    Which STM32L4?

    What hardware, your own, or a "known good one" like Nucleo or Disco?

    How do you clock the RTC, from LSI or LSE? If LSE, try LSI and report back.

    Have you tried to apply a backup-domain reset at the reset, in case your problem is related to the VBAT-brownout erratum?

    JW

    SujithAuthor
    Visitor II
    October 23, 2024

    Hi,
    Thank you for your response. I'm using an STM32L412RBT6 microcontroller. The RTC is currently clocked from the LSE (32kHz external crystal), but I am facing an issue where the LSE does not seem to generate a wave. When I switch to LSI (Low-Speed Internal), the RTC works fine, but I would like to use the LSE for more accurate timing.

    Here’s a summary of the situation:

    Microcontroller: STM32L412RBT6
    RTC clock source: LSE (32kHz crystal) – not generating a wave.
    Switching to LSI: RTC works fine with LSI.
    Could you suggest the correct method to check hardware-related issues for LSE? Should I apply the backup-domain reset as you mentioned, and how do I ensure the LSE is properly configured?

    Thanks for your help!

    Sujith

    Super User
    October 23, 2024

    Hi,

    try set the LSEDRIVE to high (11) , to have it working with your crystal.

    SujithAuthor
    Visitor II
    October 24, 2024

    Hello STM32 Community,

    I’m encountering an issue with the RTC on my STM32L412RBT6 microcontroller. The RTC works fine when a battery is used for the VBAT pin, but when I connect VDD directly to VBAT (without using a battery), the RTC stops functioning.

    Here’s the situation:

    • Microcontroller: STM32L412RBT6
    • RTC clock source: LSE (32kHz external crystal) – not generating a wave.
    • Switching to LSI: RTC works fine with LSI, but I need the accuracy of the LSE.
    • VDD connected to VBAT: When I connect VDD directly to VBAT, the RTC does not function.
    • Using a battery on VBAT: When I use a battery, the RTC works as expected.

    Steps I’ve Taken:

    • I tried setting the LSE drive to high (LSEDRV = 11), but the LSE input is still low, so the output remains low, and the RTC doesn’t work.

    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?
    4. Could this issue be related to the LSE configuration, and should I perform a backup-domain reset to resolve the LSE not generating a wave?
    5. Are there any specific hardware-related checks or configurations to ensure the LSE works properly?

    Any insights or recommendations to resolve this issue would be greatly appreciated!

    Thank you for your help!

    Sujith

    Visitor II
    October 24, 2024

    Ensure the crystal is properly connected and consider checking the PCB layout for any potential issues. Also, a backup-domain reset might help clear any stale configurations affecting the RTC operation

    Super User
    October 24, 2024

    How exactly do you check that RTC works/does not work?

    Do you use a Nucleo board, or is this your own?

    In latter case, describe the ground/power arrangement and/or post relevant portion of schematics and/or layout.

    Btw. don't probe the crystal directly using oscilloscope as the LSE is an ultralow power circuit and capacitance of oscilloscope probe may affect the oscillator to the point that it stops oscillation.

    Performing backup domain reset before starting LSE/RTC should make no harm and may remedy the backup-domain-brownout issue, should it occur.

    JW

    Graduate
    October 24, 2024

    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.

    SujithAuthor
    Visitor II
    October 25, 2024

    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).
    Graduate
    October 25, 2024

    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.

     

    Graduate
    October 25, 2024

    @mƎALLEm, @STTwo-32

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

    SujithAuthorAnswer
    Visitor II
    October 25, 2024

    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