void DS1302_DispalyTime(void)
{
uchar temp;
temp=(time_buf[0]>>4)+0; //年显示
LCD_Write_Byte(1,0,temp);
temp=(time_buf[0]&0x0f)+0;
LCD_Write_Byte(1,1,temp);
temp=(time_buf[1]>>4)+0;
LCD_Write_Byte(1,2,temp);
temp=(time_buf[1]&0x0f)+0;
LCD_Write_Byte(1,3,temp);
LCD_Write_Byte(1,4,-);
temp=(time_buf[2]>>4)+0; //月显示
LCD_Write_Byte(1,5,temp);
temp=(time_buf[2]&0x0f)+0;
LCD_Write_Byte(1,6,temp);
LCD_Write_Byte(1,7,-);
temp=(time_buf[3]>>4)+0; //日显示
LCD_Write_Byte(1,8,temp);
temp=(time_buf[3]&0x0f)+0;
LCD_Write_Byte(1,9,temp);
LCD_Write_Str(2,0,"week:"); //星期显示
temp=(time_buf[4])+0;
LCD_Write_Byte(2,5,temp);
temp=(time_buf[5]>>4)+0; //时显示
LCD_Write_Byte(2,8,temp);
temp=(time_buf[5]&0x0f)+0;
LCD_Write_Byte(2,9,temp);
LCD_Write_Byte(2,10,:);
temp=(time_buf[6]>>4)+0; //分显示
LCD_Write_Byte(2,11,temp);
temp=(time_buf[6]&0x0f)+0;
LCD_Write_Byte(2,12,temp);
LCD_Write_Byte(2,13,:);
temp=(time_buf[7]>>4)+0; //秒显示
LCD_Write_Byte(2,14,temp);
temp=(time_buf[7]&0x0f)+0;
LCD_Write_Byte(2,15,temp);
}
void DS1302_DispalyTime1(void)
{
uchar temp;
temp=(time_buf1[0]>>4)+0; //年显示
LCD_Write_Byte(1,0,temp);
temp=(time_buf1[0]&0x0f)+0;
LCD_Write_Byte(1,1,temp);
temp=(time_buf1[1]>>4)+0;
LCD_Write_Byte(1,2,temp);
temp=(time_buf1[1]&0x0f)+0;
LCD_Write_Byte(1,3,temp);
LCD_Write_Byte(1,4,-);
LCD_Write_Str(2,0,"week:"); //星期显示
temp=(time_buf1[2])+0;
LCD_Write_Byte(2,5,temp);
temp=(time_buf1[3]>>4)+0; //月显示
LCD_Write_Byte(1,5,temp);
temp=(time_buf1[3]&0x0f)+0;
LCD_Write_Byte(1,6,temp);
LCD_Write_Byte(1,7,-);
temp=(time_buf1[4]>>4)+0; //日显示
LCD_Write_Byte(1,8,temp);
temp=(time_buf1[4]&0x0f)+0;
LCD_Write_Byte(1,9,temp);
temp=(time_buf1[5]>>4)+0; //时显示
LCD_Write_Byte(2,8,temp);
temp=(time_buf1[5]&0x0f)+0;
LCD_Write_Byte(2,9,temp);
LCD_Write_Byte(2,10,:);
temp=(time_buf1[6]>>4)+0; //分显示
LCD_Write_Byte(2,11,temp);
temp=(time_buf1[6]&0x0f)+0;
LCD_Write_Byte(2,12,temp);
LCD_Write_Byte(2,13,:);
temp=(time_buf1[7]>>4)+0; //秒显示
LCD_Write_Byte(2,14,temp);
temp=(time_buf1[7]&0x0f)+0;
LCD_Write_Byte(2,15,temp);
}
void main(void)
{
port_init();
DS1302_Init();
lcd_init();
LCD_Clear();
delay(10);
//DS1302_WriteTime();
DS1302_WriteTime1();
while(1)
{
//DS1302_GetTime();
DS1302_GetTime1();
//DS1302_DispalyTime(); //注释掉的三条语句也是OK的,调试一下
DS1302_DispalyTime1();
}
}
protues方针图如下: