Dear Shyam , Hello.
Can you explain me about Read_RTC function ?
also the MCU is lpc2378
RTC Read_RTC(void) { RTC Local_time; Local_time.RTC_Sec = ((RTC_CTIME0 & 0x0000003F)>>0); rtcdata = ((RTC_CTIME0 & 0x0000003F)>>0); // Minute value [0-59] Local_time.RTC_Min = ((RTC_CTIME0 & 0x00003F00)>>8); // Hour value [0-23] Local_time.RTC_Hour = ((RTC_CTIME0 & 0x001F0000)>>16); // Day of week value [0-6] Local_time.RTC_Wday = ((RTC_CTIME0 & 0x07000000)>>24) ; // Day of month value [1-31] Local_time.RTC_Mday = ((RTC_CTIME1 & 0x0000001F)>>0); // Month value [1-12] Local_time.RTC_Mon = ((RTC_CTIME1 & 0x0000FF00)>>8); // Year value Local_time.RTC_Year = ((RTC_CTIME1 & 0x0FFF0000)>>16); // Day of year value [1-365] Local_time.RTC_Yday = RTC_DOY; RTC_CCR |= 0x01; return (Local_time); }
You want to know the meaning of:
RTC_CTIME0 & 0x00003F00)>>8
Did you notice the full text:
// Minute value [0-59] Local_time.RTC_Min = ((RTC_CTIME0 & 0x00003F00)>>8);
A value 0..59 requires 6 bits of storage (0..63). The comment claims that the minutes (0..59) are stored in 6 bits in the second byte of RTC_CTIME0, which is the reason it extracts the 6 bits and then shifts the result down 8 bits since the low-order byte did contain the seconds part of the time.
By the way - if you selected to create a new thread instead of replying to an existing, then now would be a good time to post a message containing a link to the original thread. Remember that other people who find this thread will not know what original thread you did read.
thank you very much for your answer. that was my first time that I used a foreign forum.and I promised this mistake never happen again.