Content originally posted in LPCWare by arturn on Fri May 31 01:57:21 MST 2013
Finally I fix '\0' bug and code runs well...
But now clock its stopped... Always return the same time.. :S
void SetStrTime(char * StrTime)
{
char year[4];
char month[2];
char day[2];
char minute[2];
char hour[2];
char second[2];
strncpy(year,StrTime,4);
year[4]='\0';
StrTime+=5;
strncpy(month,StrTime,2);
month[2]='\0';
StrTime+=3;
strncpy(day,StrTime,2);
day[2]='\0';
StrTime+=3;
strncpy(hour,StrTime,2);
hour[2]='\0';
StrTime+=3;
strncpy(minute,StrTime,2);
minute[2]='\0';
StrTime+=3;
strncpy(second,StrTime,2);
second[2]='\0';
StrTime+=3;
LPC_RTC->YEAR = atoi(year);
LPC_RTC->MONTH = atoi(month)+1;
LPC_RTC->DOM = atoi(day);
LPC_RTC->HOUR = atoi(hour);
LPC_RTC->MIN = atoi(minute);
LPC_RTC->SEC = atoi(second);
}
void GetStrTime(char * StrTime)
{
STRCLEAN(StrTime);
sprintf(StrTime,"%04i-%02i-%02iT%02i:%02i:%02i",LPC_RTC->YEAR,LPC_RTC->MONTH - 1,LPC_RTC->DOM,LPC_RTC->HOUR,LPC_RTC->MIN,LPC_RTC->SEC);
}