设计制作实时时间显示、日期显示和位置显示,但是程序设计编译好后发现时间中的秒不能按秒刷新。其余的到没发现问题。请大家帮忙看下我的程序因为什么地方导致的不能按秒进行刷新。代码如下:
Uart_Init();
while(1)
{
if(Flag_GPS_OK == 1 && RX_Buffer[4] == 'G' && RX_Buffer[6] == ',' && RX_Buffer[13] == '.') //确定是否收到"GPGGA"这一帧数据
{
for( i = 0; i < 68 ; i++)
{
Display_GPGGA_Buffer[i] = RX_Buffer[i];
}
Hour = (Display_GPGGA_Buffer[7]-0x30)*10+(Display_GPGGA_Buffer[8]-0x30)+8; //UTC时间转换到北京时间UTC+8
//0X30为ASCII码转换为数字
if( Hour >= 24) //溢出
{
Hour %= 24; //获取当前Hour
Flag_OV = 1; //日期进位
}
else
{
Flag_OV = 0;
}
Min_High = Display_GPGGA_Buffer[9];
Min_Low = Display_GPGGA_Buffer[10];
Sec_High = Display_GPGGA_Buffer[11];
Sec_Low = Display_GPGGA_Buffer[12];
Flag_Calc_GPGGA_OK = 1;
Delay_ms(5);
}
LCD12864_NoWaitIdle_COM_Write(0x80); //设置指针
LCD12864_write_word("★"); //显示内容
LCD12864_Data_Write(Hour/10+0x30);
LCD12864_Data_Write(Hour%10+0x30);
LCD12864_write_word("时");
LCD12864_Data_Write(Min_High);
LCD12864_Data_Write(Min_Low);
LCD12864_write_word("分");
LCD12864_Data_Write(Sec_High);
LCD12864_Data_Write(Sec_Low);
LCD12864_write_word("秒");
LCD12864_write_word("★");
LCD12864_NoWaitIdle_COM_Write(0x98); //设置指针
LCD12864_write_word("纬度:"); //显示内容
LCD12864_Data_Write(Display_GPGGA_Buffer[28]); //N 或者 S
LCD12864_Data_Write(' ');
LCD12864_Data_Write(Display_GPGGA_Buffer[17]); //纬度
LCD12864_Data_Write(Display_GPGGA_Buffer[18]); //纬度
LCD12864_write_word("°");
LCD12864_Data_Write(Display_GPGGA_Buffer[19]); //纬度
LCD12864_Data_Write(Display_GPGGA_Buffer[20]); //纬度
LCD12864_write_word("' ");
LCD12864_NoWaitIdle_COM_Write(0x88); //设置指针
LCD12864_write_word("经度:"); //显示内容
LCD12864_Data_Write(Display_GPGGA_Buffer[42]); //E 或者 W
LCD12864_Data_Write(Display_GPGGA_Buffer[30]); //经度
LCD12864_Data_Write(Display_GPGGA_Buffer[31]);
LCD12864_Data_Write(Display_GPGGA_Buffer[32]);
LCD12864_write_word("°");
LCD12864_Data_Write(Display_GPGGA_Buffer[33]);
LCD12864_Data_Write(Display_GPGGA_Buffer[34]);
LCD12864_write_word("' ");
if(Flag_GPS_OK == 1 && RX_Buffer[4] == 'M' && RX_Buffer[52] == ',' && RX_Buffer[59] == ',') //确定是否收到"GPRMC"这一帧数据
{
for( i = 0; i < 68 ; i++)
{
Display_GPRMC_Buffer[i] = RX_Buffer[i];
}
Year_High = Display_GPRMC_Buffer[57];
Year_Low = Display_GPRMC_Buffer[58];
Month_High = Display_GPRMC_Buffer[55];
Month_Low = Display_GPRMC_Buffer[56];
Day_High = Display_GPRMC_Buffer[53];
Day_Low = Display_GPRMC_Buffer[54];
if(Flag_OV == 1) //有进位
{
UTCDate2LocalDate(); //UTC日期转换为北京时间
}
Flag_Calc_GPRMC_OK = 1;
Delay_ms(5);
}
LCD12864_NoWaitIdle_COM_Write(0x90); //设置指针
LCD12864_write_word("20");
LCD12864_Data_Write(Year_High);
LCD12864_Data_Write(Year_Low);
LCD12864_write_word("年");
LCD12864_Data_Write(Month_High);
LCD12864_Data_Write(Month_Low);
LCD12864_write_word("月");
LCD12864_Data_Write(Day_High);
LCD12864_Data_Write(Day_Low);
LCD12864_write_word("日");
}
}
}