void main()
{
unsigned char clock[4];
unsigned char sec;
TRISC=0;
Lcd_Init(&PORTC);
Lcd_Cmd(LCD_CURSOR_OFF);
Lcd_Cmd(LCD_CLEAR);
T0CON=0x05;
TMR0H=0xC2;
TMR0L=0xF7;
INTCON.TMR0IF=0;
T0CON.TMR0ON=1;
while(1)
{
Lcd_Chr(1,6,clock[0]+48);
Lcd_Chr(1,7,clock[1]+48);
Lcd_Chr(1,8,':');
Lcd_Chr(1,9,clock[2]+48);
Lcd_Chr(1,10,clock[3]+48);
while(!INTCON.TMR0IF);
T0CON.TMR0ON=0;
sec++;
if(sec>59)
{
sec=0;
clock[3]++;
}
if(clock[3]>9)
{
clock[3]=0;
clock[2]++;
}
if(clock[2]>5)
{
clock[2]=0;
clock[1]++;
}
if(clock[1]>9)
{
clock[1]=0;
clock[0]++;
}
if(clock[0]==2&&clock[1]>3)
{
clock[0]=0;
clock[1]=0;
}
TMR0H=0xC2;
TMR0L=0xF7;
INTCON.TMR0IF=0;
T0CON.TMR0ON=1;
Lcd_Cmd(LCD_CLEAR);
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น