RTC_GETTIME () and RTC_GETDATE () were ordered in different order, the time should be read first and then the date should be read, then OK!
void set_time(struct time_st *t) {
c_datetypedef date_value;
RTC_TimeTypeDef time_value;
te_value. RTC_Date = t->; D; .
date_value RTC_Month = t – & gt; M; .
date_value RTC_WeekDay = t – & gt; W; .
date_value RTC_Year = t – & gt; Y;
RTC_SetDate (RTC_Format_BIN, & amp; date_value);// set date
void set_time(struct time_st *t) {
c_datetypedef date_value;
RTC_TimeTypeDef time_value;
te_value. RTC_Date = t->; D; .
date_value RTC_Month = t – & gt; M; .
date_value RTC_WeekDay = t – & gt; W; .
date_value RTC_Year = t – & gt; Y;
RTC_SetDate (RTC_Format_BIN, & amp; date_value);// set date
time_value. RTC_H12 = RTC_H12_AM; .
time_value RTC_Hours = t – & gt; h; .
time_value RTC_Minutes = t – & gt; m; .
time_value RTC_Seconds = t – & gt; s;
RTC_SetTime (RTC_Format_BIN, & amp; time_value); // Set time
}
Void get_time(struct time_st *t, struct time_st *t, struct time_st *t, struct time_st *t);
RTC_TimeTypeDef time_value;
RTC_GetTime (RTC_Format_BIN, & amp; time_value);
RTC_GetDate(RTC_Format_BIN,& date_value);
->; Y = date_value.RTC_Year;
t – & gt; M = date_value.RTC_Month;
t – & gt; D = date_value.RTC_Date;
t – & gt; W = date_value.RTC_WeekDay;
t – & gt; h = time_value.RTC_Hours;
t – & gt; m = time_value.RTC_Minutes;
t – & gt; s = time_value.RTC_Seconds;
}
Read More:
- Stm32f107 kernel file — stm32f10x. H
- Stm32f103c8t6 in keil compiler error: # 67: expected a “}” solution
- [Error resolution] paramiko.ssh_exception.SSHException: Error reading SSH protocol banner setting
- How to get the current time in java time string
- Time, strftime and strptime in Python
- Shell gets the current time of the system and formats it
- The time of the time database displayed by the front end is inconsistent
- The shell gets the current time of the system and formats it
- Register global time filter in main.js in Vue
- Mac — Open keyboard F1 – F12 function key
- Docker command error during connect: get http://2F2F.2Fpipe2Fdocker_ engine/v1.36/containers/json: open//.
- Event resolution of component {b3118b2-1f49-48e5-b6f5-bc21caec56fb}
- After switching the tidb database, an error could not commit JDBC transaction appears from time to time
- Apache [error] server reached MaxClients setting, consider raising the MaxClients setting
- When calling time module – time / datetime in wxPython, an error is reported. Valueerror: unknown locale: zh cn
- ‘Conversion failed when converting date and/or time from character string.DB-Lib error message 241,
- Destructor abnormal stuck bug
- [math processing error] problem solving (the difference between F5 refresh page and Ctrl / shift + F5 refresh page)
- Someone is doing something abnormal
- Cmake error solution encountered in STM32 development with clion