unsigned char H = 0;
unsigned char M = 0;
unsigned char S = 0;
unsigned long RTCTime = 0;
unsigned char TimeDisplayFlag = 0x00;
unsigned int i = 0;
unsigned char TIME[8];
void RTC_LCDDisplay(void)
{
if(i<10)
{
GPIO_Write(GPIOC,~GPIO_Pin_8); //L1
if(GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0) != Bit_SET ) //B1
{ i++;
GPIO_Write(GPIOC,0xFCFF);}
//检查时钟更新标志位
if(TimeDisplayFlag == 1) //TimeDisplayFlag时钟更新标志位
{ GPIO_Write(GPIOC,~GPIO_Pin_8);
//获取当前RTC计数值
RTCTime = RTC_GetCounter();
H = (unsigned char)(RTCTime/3600); //时
M = (unsigned char)((RTCTime%3600)/60); //分
S = (unsigned char)((RTCTime%3600)% 60); //秒
//数据处理器及LCD显示
TIME[2] = 0x3A; //':'
TIME[5] = 0x3A; //':'
if(S<10)
{
TIME[7] = S+0x30; //秒个位
TIME[6] = 0x30; //秒十位
}
else
{
TIME[7] = (S%10) + 0x30;
TIME[6] = (S/10) + 0x30;
}
if(M<10)
{
TIME[4] = M+0x30;
TIME[3] = 0x30;
}
else
{
TIME[4] = (M%10) + 0x30;
TIME[3] = (M/10) + 0x30;
}
if(H<10)
{
TIME[1] = H+0x30;
TIME[0] = 0x30;
}
else
{
TIME[1] = (H%10) + 0x30;
TIME[0] = (H/10) + 0x30;
}
LCD_SetTextColor(Black);
LCD_SetBackColor(White);
LCD_DisplayStringLine(Line9,TIME);
//清零时钟更新标志位
TimeDisplayFlag = 0;
}
}
}
不按按键前正常运行,按了按键LCD显示的数就不动了,我想RTC不计时了。刚开始其实我是想按键之后才开始计时的,我把计时部分加到按键判断里头,按一下出一个数,内部是计时的,只是LCD不是连续显示出来。按一下,LCD出一个数。新手啊,求助,谢谢
此帖出自
小平头技术问答
一周热门 更多>