2016-12-06 02:44 AM
Hi,
I'am working on STM32L486RG MCU and I'am using RTC to get the real time value.
I know that ST provides 2 RTC format for the time : the RTC_FORMAT_BIN and RTC_FORMAT_BCD ( as defined in the HAL ). I know the difference between the 2 representations but I don't know exactly when it's useful to use the BCD format
and when to use the Binary format ?
I kindly need your help .
Thanks.
2016-12-06 08:03 AM
Dear
GUIRAT.Youssef
,You can refer to this application note, it may help you:
Using the hardware real-time clock (RTC) in low-power modes withSTM32 microcontrollers.Best Regards
-Imen-
2016-12-06 08:38 AM
The RTC natively uses BCD
2016-12-06 09:50 AM
Thanks Clive , I've already checked this by referring to the reference manual.
My question is in which case is suitable to use Binary format rather than BCD format ?
Also, I've seen the RTC_TimeStamp example provided by ST and they use the BCD format to set
both Date and Time then they use Binary format to get the Date and Time . Why to do so ? Cannot we
use the same format for setting then use it again for getting the time ?
2016-12-06 10:36 AM
The digital logic is easier with the BCD data, if you plan on doing math on the numbers, ie advancing alarm settings it is easier to use binary and check overflows (>59) and daisy chain from seconds, minutes, hours, days, etc.
If you plan on taking the data and printing it the BCD data can be processed efficiently with shifts and masks rather than the more expensive printf() itoa() type implementation.