cancel
Showing results for 
Search instead for 
Did you mean: 

RTC Year?

Dick Lin
Senior
Posted on June 23, 2018 at 02:06

Hi,

Why the RTC Year is a uint8_t and value must be b/w 0 and 99? How do we map to real year? Thx

/**

* @brief RTC Date structure definition

*/

typedef struct

{

uint8_t WeekDay; /*!< Specifies the RTC Date WeekDay.

This parameter can be a value of @ref RTC_WeekDay_Definitions */

uint8_t Month; /*!< Specifies the RTC Date Month (in BCD format).

This parameter can be a value of @ref RTC_Month_Date_Definitions */

uint8_t Date; /*!< Specifies the RTC Date.

This parameter must be a number between Min_Data = 1 and Max_Data = 31 */

uint8_t Year; /*!< Specifies the RTC Date Year.

This parameter must be a number between Min_Data = 0 and Max_Data = 99 */

}RTC_DateTypeDef;

Note: this post was migrated and contained many threaded conversations, some content may be missing.
13 REPLIES 13
Tilen MAJERLE
ST Employee
Posted on June 23, 2018 at 10:41

Hello,

add 2000 in your calculations.

Best regards,

Tilen

john doe
Lead
Posted on June 23, 2018 at 13:09

>2-digit years

somebody didnt learn anything from Y2K.

Posted on June 23, 2018 at 14:39

with the ever shorter life span of equipment, Y2K wont affect the next 10 generation's of computers.

Posted on June 23, 2018 at 18:03

>>somebody didnt learn anything from Y2K.

I learned that some people have unrealistic ideas about how many decades electronic equipment is expected to function, or contain parts that can be sourced indefinitely. Probably still a warehouse somewhere still filled with Z80 and 68000 parts.

That a lot of organizations in the late part of the 20th century fired their engineering staff, and then expected to manufacture the designed equipment for 30-40 years with zero investment in design update or maintenance work.

That very few people can write calendaring software properly, and even fewer that actually test that they can.

Between 2000-2099 every forth year is a leap, this is not true for 1900-1999 or 2100-2199. The RTC implementation is simplistic/naive, as this has less gates, and less likelihood of being designed wrong.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on June 25, 2018 at 18:54

That's what I thought after posted - add 2000. Thx

Posted on June 25, 2018 at 19:14

Interesting. I got minutes over 59. Not sure what's happening...

Name : Minutes

Details:67 'C'

Default:67 'C'

Decimal:67

Hex:0x43

Binary:1000011

Octal:0103
Posted on June 25, 2018 at 19:18

In BCD there are 0x59 minutes in an hour...

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on June 25, 2018 at 19:34

I don't see there is any issue to have minutes over 59 no matter what format we are using. Here is from user's manual.

STM32L4S9xx HAL User Manual: RTC_TimeTypeDef Struct Reference

uint8_t

Specifies the RTC Time Minutes. This parameter must be a number between Min_Data = 0 and Max_Data = 59

Posted on June 25, 2018 at 19:36

Typo - I don't see there is any reason to have minutes over decimal 59.