cancel
Showing results for 
Search instead for 
Did you mean: 

RTC in binary mode not working properly on STM32F746

EPHIL.1
Associate II

Hi,

I enabled RTC and calendar on a STM32F746 CubeMX project, and I can gather correct time informations when using BCD mode from the HAL_RTC_GetTime function, but when using the other option the "binary" mode, the informations I´m getting from GetTime can be incorrect from time to time ("jumping" to incorrect values, for example from 12 to 22 seconds, then to 14 sec right after) but still switch minutes/hours at the right moment.

From what I understand the RTC calendar is basically in BCD format, which is converted to a "classical" binary format with "RTC_Bcd2ToByte" function when the format in HAL_RTC_GetTime is precised as binary, I don't understand why it would have these issues. I was wondering if anyone had came across this issue before?

Thank you in advance for your time.

5 REPLIES 5

> ("jumping" to incorrect values, for example from 12 to 22 seconds, then to 14 sec right after)

Is this an actually observed event? What were values of minutes/hours at that event?

What is the clock source for RTC? How is BYPSHD set? Does this unexpected jump occur also in native BCD readout?

JW

EPHIL.1
Associate II

Hi,

Thank you for the answer.

Yes I observed it through IAR live watch ; the minutes and hours are at 0, or at their current values at that event (I initialized the RTC mins/hours to 0).

The RTC clock source is the LSE integrated on the board (32,768 KHz). And I don't know what BYPSHD is?

The "jumps" only occur when the data format of the the RTC is set to "binary data format" in CubeMX.

> Yes I observed it through IAR live watch

What exactly do you observe? Some variable into which you read the time? Is that variable global or local? Can't some other process inadvertently overwrite it?

> And I don't know what BYPSHD is?

Sorry, BYPSHAD, a bit in RTC_CR register determining whether RTC registers are read directly or through a locking mechanism, see RTC chapter in RM.

But while there are artefacts related to this mechanism, they probably would not explain seconds value "jumping" so wildly.

JW

EPHIL.1
Associate II

Yes sorry should have detailed, in the while(1) in my main function I am currently calling :

HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);

HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN);

With sTime (and sDate) the appropriate structs, and so I am watching the sTime struct in live watch, accessing seconds, hours, etc.

Since I´m checking both time and date I shouldn´t have problem with the BYSHPAD issue? (I don't really understand where to change this bit btw)

> With sTime (and sDate) the appropriate structs, and so I am watching the sTime struct in live watch, accessing seconds, hours, etc.

As mentioned, at this point I'd suspect some other process inadvertently overwriting the seconds.

Try reducing the program to absolute minimum exhibiting the problem.

JW