中级会员
 
- 积分
- 213
- 金钱
- 213
- 注册时间
- 2012-8-24
- 在线时间
- 0 小时
|

楼主 |
发表于 2013-4-22 08:38:54
|
显示全部楼层
回复【2楼】正点原子:
回复【楼主位】caoyicheng626: --------------------------------- 得看你的时间获取函数了.
---------------------------------
u32 Time_Regulate(void)
{
u32 Tmp_HH,Tmp_MM,Tem_SS;
Tmp_HH = Hours;
Tmp_MM = Minutes;
Tem_SS = Seconds;
/*return the value to store in RTC counter register*/
return((Tmp_HH*3600 + Tmp_MM*60 + Tem_SS));
}
void Time_Display(u32 TimeVar)
{
u32 THH = 0,TMM = 0,TSS = 0;
THH = TimeVar/3600;
TMM = (TimeVar%3600)/60;
TSS = (TimeVar%3600)%60;
printf("Time: %0.2d:%0.2d:%0.2d\r\n",THH,TMM,TSS);
}
char RTC_Configuration_Flag()
{
if(BKP_ReadBackupRegister(BKP_DR1) != 0X5A5A) return 1;
else return 0;
}
int main (void)
{
SystemInit();
UART1_Init();
RTC_NVIC_Config();
if(RTC_Configuration_Flag()) RTC_Config();
printf("Program Running!\r\n");
RTC_ITConfig(RTC_IT_SEC,ENABLE);//Enable the RTC Second Interrupt(使能秒中断)
//Clear reset flag:给RCC_CSR的bit24(RMVF)置“1”来清除所有复位标志
RCC_ClearFlag();
while(1)
{
if(TimeDisplay == 1)//if 1s has passed
{
Time_Display(RTC_GetCounter());//Display current time
TimeDisplay = 0;
}
}
}
|
|