bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
Guys,
How to calculate date,month and year ? from RTC_GetCounter function,
I saw :
Please correct me .....
Any clues ?
thanks
How to calculate date,month and year ? from RTC_GetCounter function,
I saw :
Code:
uint32_t RTC_GetCounter(void)
{
uint16_t tmp = 0;
tmp = RTC->CNTL;
return (((uint32_t)RTC->CNTH << 16 ) | tmp) ;
}
I've done :
/* Load the Counter value */
Tmp = RTC_GetCounter();
/* Load the Counter value */
Tmp = RTC_GetCounter();
/* Compute day */
WEEKDAY = (Tmp / 86400)%7;
/* Compute date */
DATE = (Tmp / 86400)%360;
/* Compute month */
MONTH = (Tmp / 2629743)%12;
/* Compute year */
YEAR = (Tmp / 31556926)+1970;
Please correct me .....
Any clues ?
thanks
Last edited by a moderator: