printf("current time: %02lu:%02lu:%02lu\n",rtc_get_counter_val()/(60*60),(rtc_get_counter_val()%(60*60))/60,(rtc_get_counter_val()%60));// get and print time from internal RTC
}elseif(strlen(word)!=8||word[0]<'0'||word[0]>'2'||word[1]<'0'||word[1]>'9'||word[3]<'0'||word[3]>'5'||word[4]<'0'||word[4]>'9'||word[6]<'0'||word[6]>'5'||word[7]<'0'||word[7]>'9'){// time format is incorrect
gotoerror;
}else{
rtc_set_counter_val(((word[0]-'0')*10+(word[1]-'0')*1)*(60*60)+((word[3]-'0')*10+(word[4]-'0')*1)*60+((word[6]-'0')*10+(word[7]-'0')*1));// set time in internal RTC counter
printf("time set\n");
}
}else{
gotoerror;
}
@ -191,7 +181,7 @@ void main(void)
printf("OK\n");
uint32_tticks_time=rtc_get_counter_val();// get time from internal RTC (since first start/power up)
printf("uptime: %02lu:%02lu:%02lu\n",ticks_time/(60*60),(ticks_time%(60*60))/60,(ticks_time%60));// display time