sprintf((char*)data,"20%02d-%02d-%02d-%01d",RTC_DateStruct.RTC_Year,RTC_DateStruct.RTC_Month,RTC_DateStruct.RTC_Date,RTC_DateStruct.RTC_WeekDay); sprintf((char*)time,"%02d:%02d:%02d",RTC_TimeStruct.RTC_Hours,RTC_TimeStruct.RTC_Minutes,RTC_TimeStruct.RTC_Seconds); } //RTC闹钟功能初始...
printf("weekday %d\n", tm.weekday); tm_time.tm_year= tm.year -1900; tm_time.tm_mon= tm.month -1; tm_time.tm_mday=tm.date; tm_time.tm_hour=tm.hour; tm_time.tm_min=tm.minute; tm_time.tm_sec=tm.second; tm_time.tm_wday=tm.weekday; val_time.tv_sec= mktime(&tm_time)...
RTC_GetDate(RTC_Format_BIN,&dates_t); printf("rtc_get_date:Y:%02d,M:%02d,D:%02d,WeekDay:%02d\r\n",dates_t.RTC_Year,dates_t.RTC_Month,dates_t.RTC_Date,dates_t.RTC_WeekDay); delay_ms(1000); } }
} sDate.WeekDay = RTC_WEEKDAY_MONDAY; sDate.Month = RTC_MONTH_JANUARY; sDate.Date = 0x1; sDate.Year = 0x0; if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK) { Error_Handler(); } /** Enable the WakeUp */ if (HAL_RTCEx_SetWakeUpTimer(&hrtc, 0, RTC_WAK...
sDate.WeekDay = RTC_WEEKDAY_MONDAY; sDate.Month = RTC_MONTH_JANUARY; sDate.Date = 0x1; sDate.Year = 0x0; if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BCD) != HAL_OK) { Error_Handler(); } /** Enable the WakeUp
RTC_DateStructure.WeekDay=week; RTC_DateStructure.Year=year; return HAL_RTC_SetDate(&hrtc,&RTC_DateStructure,RTC_FORMAT_BIN); } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. ...
Init(&RTC_InitStructure);//3-设置日期RTC_DateStructure.RTC_Year = 0x21;//21年RTC_DateStructure.RTC_Month = 0x09;//9月RTC_DateStructure.RTC_Date = 0x14;//14号RTC_DateStructure.RTC_WeekDay = 0x02;//周二RTC_SetDate(RTC_Format_BCD, &RTC_DateStructure);//4-时间设置 时分秒 16:06:00...
RTC_AlarmTypeInitStructure.RTC_AlarmDateWeekDay=week;//星期 RTC_AlarmTypeInitStructure.RTC_AlarmDateWeekDaySel=RTC_AlarmDateWeekDaySel_WeekDay;//按星期闹 RTC_AlarmTypeInitStructure.RTC_AlarmMask=RTC_AlarmMask_None;//精确匹配星期,时分秒 RTC_AlarmTypeInitStructure.RTC_AlarmTime=RTC_TimeTypeInitStructure;...
RTC_WeekDay=week; RTC_DateTypeInitStructure.RTC_Year=year; return RTC_SetDate(RTC_Format_BIN,&RTC_DateTypeInitStructure); } //RTC初始化 //返回值:0,初始化成功; // 1,LSE开启失败; // 2,进入初始化模式失败; u8 My_RTC_Init(void) { RTC_InitTypeDef RTC_InitStructure; u16 retry=0X1FFF; ...
//week:星期几(1~7) @ref RTC_WeekDay_Definitions //hour,min,sec:小时,分钟,秒钟 void RTC_Set_AlarmA(u8 week,u8 hour,u8 min,u8 sec) { RTC_AlarmTypeDef RTC_AlarmSturuct; RTC_AlarmSturuct.AlarmTime.Hours=hour; //小时 RTC_AlarmSturuct.AlarmTime.Minutes=min; //分钟 RTC_AlarmSturuct.Al...