Skip to main content
Prisma
Associate II
May 27, 2021
Solved

RTC reset with VBATT

  • May 27, 2021
  • 6 replies
  • 1631 views

Hi,

I have an STM32G0 with VBATT input for the RTC.

When I restart the circuit, the time is reset.

At the power On I write this instruction :

 HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1);

Before of the Power Off :

HAL_RTCEx_BKUPWrite(&hrtc, RTC_BKP_DR1, 0x32F2);

Thanks for your Help.

Pascal

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

Hi Jan,

thank you. Solved the problem.

It was a mistake during the RTC init() setup.

Thank you for your help !!

Pascal

6 replies

waclawek.jan
Super User
May 27, 2021

Is battery connected to the VBAT pin? What is its voltage, measured directly on that pin?

How does writing to backup register relate to time of RTC?

Is that backup register content retained during powerdown?

JW

Prisma
PrismaAuthor
Associate II
May 27, 2021

Hi Jan,

thanks for your help.

On the Pin = 2.7 V

How does writing to backup register relate to time of RTC?

I don't know how to write the current time on the register.

Is that backup register content retained during powerdown?

how can i check?

Thanks, Pascal

waclawek.jan
Super User
May 27, 2021

>> How does writing to backup register relate to time of RTC?

> I don't know how to write the current time on the register.

Why do you need to write it? And what is 0x32F2?

> At the power On I write this instruction :

> HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1);

And what does that function return?

JW

Prisma
PrismaAuthor
Associate II
May 27, 2021

Hi Jan,

Time=HAL_RTCEx_BKUPRead(&hrtc, RTC_BKP_DR1);

Return Time= 11001011110010

What is the correct instructions for read the time and date after the Power On of the circuit ?

Thanks for your help.

Pascal

waclawek.jan
Super User
May 27, 2021

> What is the correct instructions for read the time and date after the Power On of the circuit ?

It does not differ from reading the time and date in any other instance... Normally, just read RTC->TR and RTC->DR (in this order, if BYPSHAD is 0).

I don't use Cube.

JW

Prisma
PrismaAuthorBest answer
Associate II
May 27, 2021

Hi Jan,

thank you. Solved the problem.

It was a mistake during the RTC init() setup.

Thank you for your help !!

Pascal