色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 數(shù)碼管顯示的電子時(shí)鐘C51程序

          數(shù)碼管顯示的電子時(shí)鐘C51程序

          作者: 時(shí)間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          /*************************************************************
          功能:    實(shí)現(xiàn)電子時(shí)鐘顯示(C)定義:    P3口位選,P1口段選,P0.0,P0.1,P0.2為調(diào)時(shí)口時(shí)間:    2010—11—26說明:    仿真存在問題,這可能是仿真軟件的問題,需要將段位掃描反調(diào)實(shí)際運(yùn)行的結(jié)果是正確的*************************************************************/#include unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00};unsigned char dispbitcode[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};unsigned char dispbuf[8]={0,0,16,0,0,16,0,0};unsigned char dispbitcnt;unsigned char second;unsigned char minite;unsigned char hour;unsigned int tcnt;unsigned char mstcnt;unsigned char i,j;void main(void){TMOD=0x02;TH0=0x06;TL0=0x06;TR0=1;ET0=1;EA=1;while(1){if(P0_0==0){for(i=5;i>0;i--)for(j=248;j>0;j--);if(P0_0==0){second++;if(second==60){second=0;}dispbuf[0]=second%10;dispbuf[1]=second/10;while(P0_0==0);}}if(P0_1==0){for(i=5;i>0;i--)for(j=248;j>0;j--);if(P0_1==0){minite++;if(minite==60){minite=0;}dispbuf[3]=minite%10;dispbuf[4]=minite/10;while(P0_1==0);}}if(P0_2==0){for(i=5;i>0;i--)for(j=248;j>0;j--);if(P0_2==0){hour++;if(hour==24){hour=0;}dispbuf[6]=hour%10;dispbuf[7]=hour/10;while(P0_2==0);}}}}void t0(void) interrupt 1 using 0{mstcnt++;if(mstcnt==8){mstcnt=0;P1=dispcode[dispbuf[dispbitcnt]];P3=dispbitcode[dispbitcnt];dispbitcnt++;if(dispbitcnt==8){dispbitcnt=0;}}tcnt++;if(tcnt==4000){tcnt=0;second++;if(second==60){second=0;minite++;if(minite==60){minite=0;hour++;if(hour==24){hour=0;}}}dispbuf[0]=second%10;dispbuf[1]=second/10;dispbuf[3]=minite%10;dispbuf[4]=minite/10;dispbuf[6]=hour%10;dispbuf[7]=hour/10;}}
          				
                      
                          
          			
          							
          上一頁(yè) 1 2 下一頁(yè)

          評(píng)論


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

          關(guān)閉