2010-06-18 12:15 AM
using fprintf problem
2011-05-17 04:55 AM
Please be more specific. How are you sending this time number? Serial I preaume (UART)? Are you sending this number in ascii or binary format ? If ascii than assuming the number is received into a buffer called buffer that is null terminated the code to set the time would look something like this
RTC_SetCounter( (u32)atol(buffer) );2011-05-17 04:55 AM
You are receiving a 4 byte number (time_t). You can use this number directly in a function such as gmtime(). This will convert your number into a tm structure. You can use asctime() to convert the tm structure to a string. You can use mktime() to convert the tm structure back to a time_t number.
struct tm {
int tm_sec; // seconds after the minute - [0,59]
int tm_min; // minutes after the hour - [0,59]
int tm_hour; // hours since midnight - [0,23]
int tm_mday; // day of the month - [1,31]
int tm_mon; // months since January - [0,11]
int tm_year; // years since 1900
int tm_wday; // days since Sunday - [0,6]
int tm_yday; // days since January 1 - [0,365]
int tm_isdst; // daylight savings time flag
};