can someone explain why in stm32_rtc_tm2bcd the tm_year is minus 100 years.
And in stm32_rtc_bcd2tm it is plus 100 years ?
i dont get it, the years register only has years tens and years units, of which both are 4bits wide, thus can only hold 99 years max
Is this a bug ?
chrtlib.c
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14892
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: chrtlib.c
This is a question that barthess could answer, I am not very inside that part of the code.
Giovanni
Giovanni
Re: chrtlib.c
I assume this is to be compliant to c standard for the struct tm which stores tm_year as years since 1900 (see http://www.cplusplus.com/reference/ctime/tm/). This would make the RTC time base January 1, 2000.
Re: chrtlib.c
skute wrote:I assume this is to be compliant to c standard for the struct tm which stores tm_year as years since 1900 (see http://www.cplusplus.com/reference/ctime/tm/). This would make the RTC time base January 1, 2000.
So im setting date with the following input argv[1] = "24/02/14"
t.tm_mon = atoi( (const char *)&argv[1][3] );
t.tm_mday = atoi( (const char *)&argv[1][0] );
t.tm_year = atoi( (const char *)&argv[1][6] );
rtcSetTimeTm( &RTCD1, &t );
thus t.tm_year is equal to 14, i take it this is not correct then ?
What your saying is i should do
t.tm_year = atoi( (const char *)&argv[1][6] ) + 100;
Thus is amount of years from 1900 ?