利用RTC生成亚秒级时钟 |
您所在的位置:网站首页 › windows下编程语言实现亚秒级休眠 › 利用RTC生成亚秒级时钟 |
利用RTC生成亚秒级时钟的步骤: 1.打开STM32CubeMx,使能RTC。 2.配置分频器数值、初始时间,日期 3.生成代码。 4.在主函数中调用代码并输出。 RTC_TimeTypeDef stimestructure; RTC_DateTypeDef sdatestructure; HAL_RTC_GetTime(&hrtc, &stimestructure, RTC_FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &sdatestructure, RTC_FORMAT_BIN); fsecond=(float)stimestructure.Seconds+(float)(15999-stimestructure.SubSeconds)/16000; printf("%02d/%02d/%02d\r\n",2000 + sdatestructure.Year, sdatestructure.Month, sdatestructure.Date); printf("%02d:%02d:%f\r\n",stimestructure.Hours, stimestructure.Minutes,fsecond);
|
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |