用定時(shí)器實(shí)現(xiàn)的1602可調(diào)電子鐘 作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對(duì)面交流海量資料庫(kù)查詢 收藏 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í)器中斷處理函數(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();} } 上一頁(yè) 1 2 下一頁(yè)
評(píng)論