AnsweredAssumed Answered

Problems with cube implementation of get/set for RTC

Question asked by brown.geoffrey.001 on Jun 16, 2016
The cube hal code for getting and setting the time/date have some significant issues -- at the very least the documentation is woefully inadequate.

The fundamental issue is that setting (getting) time/date requires two separate memory writes (reads).  As the ST application note points out, there is a convoluted process for each of these to ensure freedom from atomicity problems.  

Unfortunately the HAL separates the date/time functions so that setting the time/date causes the initialization state to be entered/exited twice.  In a related post I read something about a requirement that set time be followed by set date -- but this isn't documented and it isn't clear that the code does the right thing in this case anyway.

Reading is even more complicated because the app note suggests a hack of multiple reads and comparing results. This isn't done in the HAL.

It makes no sense and is unsafe to separate the time/date read (or write) functions -- they should be a single atomic piece of code.   I shudder to think how threading might impact the code as written.

Of course, this would have been way easier with a better hardware design.  

Geoffrey

Outcomes