cancel
Showing results for 
Search instead for 
Did you mean: 

RTC time greater than 24 hours

AlfRomeo
Associate III

Hello everyone, I am using an internal RTC on STM32L431. After running for 23:59:59 seconds, the time changes to 24:00:00 instead of 00:00:00, and the week day has not been incremented. Why is this?

10 REPLIES 10
Sarra.S
ST Employee

Hello @AlfRomeo

Is the RTC correctly configured to use the 24-hour format? 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

As @Sarra.S said above, you probably have set the RTC inadvertently to 12 hour format, probably because of uninitialized struct when calling Cube/HAL functions setting time.

JW

The format of the hour is still 24 hours, and I haven't changed it

Uwe Bonnes
Principal III

Does the RTC continue with 24:01 ? Otherwise, where is the problem?


@Uwe Bonnes wrote:

Otherwise, where is the problem?


24:00 is never a valid time - it should go from 23:59:59.999 to 00:00


@AlfRomeo wrote:

The format of the hour is still 24 hours, and I haven't changed it


Did you follow @waclawek.jan's link - to details about the issues with uninitialised or incompletely-initialised config structures?

> The format of the hour is still 24 hours, and I haven't changed it

Read out and check/post the RTC registers content.

JW

At the time of debugging, the time continued to run after 24:00:00 seconds and changed to 00:00:00 after 39:59:59 seconds, but the week did not increase

不知道为什么,但是停电后重置后,它又好转了。该代码没有更改任何内容,除了在获取 clock 时在 hour, minute, and second 之后执行模运算。其他一切都没有改变。起初,更改此设置后,问题仍然存在,没有停电。然而,停电后,问题消失了,我感到非常困惑