新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 用定時(shí)器實(shí)現(xiàn)的1602可調(diào)電子鐘

用定時(shí)器實(shí)現(xiàn)的1602可調(diào)電子鐘

作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
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)論


技術(shù)專區(qū)

關(guān)閉