stm32的rtc与外界时间怎么校准的

2024-11-29 07:51:06
推荐回答(1个)
回答1:

char *wday[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
time_t timep;
struct tm *p;
time(&timep);
p=localtime(&timep); /*取得当地时间*/

把这个加到RTC初始化下配置时间里面试试

printf ("%d%d%d ", (1900+p->tm_year),( 1+p->tm_mon), p->tm_mday);
printf("%s%d:%d:%d\n", wday[p->tm_wday],p->tm_hour, p->tm_min, p->tm_sec);
把这个放到RTC秒中断的服务函数里面试试