您的位置 首页 培训

STM32 RTC测验成功 _只显示 时分秒

源文件位置STM32F10x_StdPeriph_Lib_V3.1.2\Project\STM32F10x_StdPeriph_Examples\RTC\Calendar仔细阅读其中的readme摘抄

源文件方位 STM32F10x_StdPeriph_Lib_V3.1.2\Project\STM32F10x_StdPeriph_Examples\RTC\Calendar

仔细阅读其间的readme
摘录如下
@par How to use it ?
In order to make the program work, you must do the following :
– Create a project and setup all project configuration
– Add the required Library files :
– stm32f10x_gpio.c
– stm32f10x_rcc.c
– stm32f10x_rtc.c
– stm32f10x_bkp.c
– stm32f10x_pwr.c
– misc.c
– stm32f10x_usart.c
– stm32f10x_exti.c
– system_stm32f10x.c (under Libraries\CMSIS\Core\CM3)
– stm32_eval.c (under Utilities\STM32_EVAL)
– Edit stm32f10x.h file to select the device you are working on.
– Edit stm32_eval.h file to select the evaluation board you will use.

依据之前的经历 树立工程

options中主张选上 use microLIB

现在的时刻,睡觉啦

程序地址

RTC测验成功
转自Tony嵌入式论坛,地址:http://www.cevx.com/bbs/thread-26329-1-1.html

=========================================================

要害代码剖析

/**
* @brief Returns the time entered by user, using Hyperterminal.
* @param None
* @retval Current time RTC counter value
*/
uint32_t Time_Regulate(void)
{
uint32_t Tmp_HH = 0xFF, Tmp_MM = 0xFF, Tmp_SS = 0xFF;

printf(“\r\n==============Time Settings=====================================”);
printf(“\r\n Please Set Hours”);

while (Tmp_HH == 0xFF)
{
Tmp_HH = USART_Scanf(23);//若超级终端输入的数据大于23,超级终端提示犯错
}
printf(“: %d”, Tmp_HH);
printf(“\r\n Please Set Minutes”);
while (Tmp_MM == 0xFF)
{
Tmp_MM = USART_Scanf(59);
}
printf(“: %d”, Tmp_MM);
printf(“\r\n Please Set Seconds”);
while (Tmp_SS == 0xFF)
{
Tmp_SS = USART_Scanf(59);
}
printf(“: %d”, Tmp_SS);

/* Return the value to store in RTC counter register */
return((Tmp_HH*3600 + Tmp_MM*60 + Tmp_SS));
}

————————————–

/**
* @brief Displays the current time.
* @param TimeVar: RTC counter value.
* @retval None
*/
void Time_Display(uint32_t TimeVar)
{
uint32_t THH = 0, TMM = 0, TSS = 0;

/* Compute hours */
THH = TimeVar / 3600;
/* Compute minutes */
TMM = (TimeVar % 3600) / 60;
/* Compute seconds */
TSS = (TimeVar % 3600) % 60;

printf(“Time: %0.2d:%0.2d:%0.2d\r”, THH, TMM, TSS);//\r回车,光标移到本行首
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/changshang/peixun/272998.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部