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
* @brief RTC Date structure definition */typedef struct{uint8_t WeekDay;/*!< Specifies the RTC Date WeekDay. This parameter can be a value of @ref RTC_WeekDay_Definitions */uint8_t Month;/*!< Specifies the RTC Date Month (in BCD format). This parameter can be a value of @ref R...
voidShowTime(void){RTC_TimeTypeDef RTC_TimeStruct={0};RTC_DateTypeDef RTC_DateStruct={0};staticuint8_t*WeekdayStr[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};staticuint8_t*H12AMPMStr[2][2]={{"AM","PM"},{"",""}};RTC_GetDate(&RTC_DateStruct);// 取用当前日期,BC...
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_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; ...
使用STM32F407时用到片上RTC万年历功能,初始化成功后利用串口控制台设置日期和时间,设置成功后再读出发现年份不一致。比如设置的时间是 2025-1-15 而读出的确是 2045-1-15 。 图1.写入时间的日期与读出日期不一致 写入日期和时间的函数如下,晃眼一看好像也没什么问题。仿真调试时发现写入的 WeekDay 的值为 0x...
p_tm->weekday =0;return0; }intmain(intargc,constchar*argv[]) {structtm tm_time;structtimeval val_time; rtc_time_t tm; reg_data_t regv;intret = -1;intfd = -1;constchar*dev_name ="/dev/hi_rtc";charstring[50] = {0};if(argc <2){ ...
RTC_AlarmMask_All(全部无效) uint32_t RTC_AlarmDateWeekDaySel; //闹钟日期或者星期选择。要想这个配置有效,RTC_AlarmMask不能配置 为RTC_AlarmMask_DateWeekDay,否则会被MASK掉。 RTC_AlarmDateWeekDaySel_Date (日期) RTC_AlarmDateWeekDaySel_WeekDay(星期) uint8_t RTC_AlarmDateWeekDay; //具体的日期或...
RTC_DateStruct.RTC_WeekDay = week; return RTC_SetDate(RTC_Format_BIN, &RTC_DateStruct); } //RTC初始化 u8 MY_RTC_Init(void) { u16 retry = 0x1fff; RTC_InitTypeDef RTC_InitStruct; //使能PWR时钟 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); ...
//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...