Other Parts Discussed in Thread: MSP430F5438
Hi, we are setting the RTC to synch with the date of a PC. We get the correct serial data from the computer on the UART port and then convert the data to BCD to store the time. Somehow , even though we are changing the register with the correct value, the registry does not store the correct day.
For example, if I put 0x23 on the RTCDAY register value will be changed to 0x22. This would happen to me with the RTCHOUR register but somehow setting the RTCM0 and RTCM1 got it fixed.
This is the snippet of code that takes the received data and stores on the register.
void update_time(){
char time_updating[]="Updating Time";
ClearDisplay();
writeToPos(0x04, time_updating);
char rtc_registers[7] = { 0 };
/*CALL THE FUNCTION AT CONTROL.H*/
update_time_from_PC( rtc_registers, 7 );
unsigned char year_low = rtc_registers[0];
unsigned char month = rtc_registers[1];
unsigned char day = rtc_registers[2];
unsigned char dow = rtc_registers[3];
unsigned char hour = rtc_registers[4];
unsigned char min = rtc_registers[5];
unsigned char sec = rtc_registers[6];
RTCCTL01|=RTCHOLD+RTCBCD+RTCMODE+RTCTEVIE;
RTCTIM0=0x0000;
RTCTIM1=0x0000;
RTCDATE=0x0000;
RTCYEAR = 0x0000;
RTCMON = 0x00;
RTCDAY = 0x00;
RTCDOW = 0x00;
RTCHOUR = 0x00;
RTCMIN = 0x00;
RTCSEC = 0x00;
year_low = bcd(year_low);
RTCYEAR = 0x2000+year_low;
month = bcd(month);
RTCMON = month ;
day = bcd(day);
RTCDAY = day ;
dow = bcd(dow);
RTCDOW = dow;
hour = bcd(hour);
RTCHOUR = hour ;
min = bcd(min);
RTCMIN = min;
sec = bcd(sec);
RTCSEC = sec;
RTCCTL01&=~RTCHOLD;
}
I tried clearing all the values before storing them but still it doesn't work.
Thanks for your help.
