用定時器實現(xiàn)的1602可調(diào)電子鐘 作者: 時間:2016-11-29 來源:網(wǎng)絡 加入技術交流群 掃碼加入和技術大咖面對面交流海量資料庫查詢 收藏 void init (){en=0;TMOD=0x01;TH0=(65536-50000)/256;TL0=(65536-50000)%256;EA=1;ET0=1;TR0=1;write_cmd(0x38);write_cmd(0x0c);write_cmd(0x06);write_cmd(0x01);hour=14;minute=59;second=55;}void timer0 () interrupt 1 //定時器中斷處理函數(shù){TH0=(65536-50000)/256;TL0=(65536-50000)%256;count++;if(count==18){count=0;second++;if(second==60){second=0;minute++;if(minute==60){minute=0;hour++;if(hour==24){hour=0;}display(2,hour); }display(5,minute);} display(8,second);} }void main (){uchar i;init();write_cmd(0x80);for(i=0;i<15;i++){write_byte(table[i]);delay1(5);}write_cmd(0x80+0x40);for(i=0;i<13;i++){write_byte(table1[i]);delay1(5);} while(1){keyscan();} } 上一頁 1 2 下一頁
評論