欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3968|回復: 3
收起左側

基于51的頻率器分享(自動換擋,每秒自動更新)。入門欣賞用

[復制鏈接]
ID:76190 發表于 2015-4-5 18:15 | 顯示全部樓層 |閱讀模式
//功能:4位數碼管顯示頻率,單位KHZ。 比如顯示 0.005=5HZ   00.05=50HZ   000.5=500HZ   0005.=5000HZ
//硬件:2051單片機,P1.6到P1.0分別是 A到G,P1.7=DP,P3.5=D4,P3.4=D3,P3.1=D2,P3.0=D1
//       晶振;12Mhz
//使用說明:自動換擋,每秒自動更新輸入頻率
//注明:該程序不是最終程序,更新程序請聯系中山董豪
//建議改進增加晶振到24MHZ,以提高量程。
#include <reg52.h>               
#define uint unsigned int        
#define uchar unsigned char     

uchar one,two,three,four,five,six,seven;    //SEVEN最高位
uchar oneo,twoo,threeo,fouro,fiveo,sixo,seveno;
uchar dp4,dp3,dp2,dp1;
                                                                                                   

uchar code display[]={0x7E,0x30,0x6D,0x79,0x33,0x5B,0x5F,0x70,0x7F,0x7B,0x00}; //七段譯碼 P1.6=A
sbit DP=P1^7;
sbit P3_0=P3^0;
sbit P3_1=P3^1;
sbit P3_4=P3^4;
sbit P3_5=P3^5;
void main()
{   TMOD=0X11;
EA=1;
ET0=1; //1S   ,change gear
ET1=1; //DISPLAY
EX0=1; //INPUT : counter
IT0=1;   
PT0=1;
PX0=1;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TH1=(65536-6000)/256;
TL1=(65536-6000)%256;
TR0=1;
TR1=1;
while(1);
}

void int0() interrupt 0 using 0   
{ ////////////////////////////////////////////////////////////////// counter
   if(one<9)
   one++;
else
{one=0;
   if(two<9)
   two++;
   else
   {two=0;
    if(three<9)
    three++;
    else
    {three=0;
     if(four<9)
     four++;
     else
     {four=0;
      if(five<9)
      five++;
      else
      {five=0;
       if(six<9)
       six++;
       else
       {six=0;
        if(seven<9)
         seven++;
         else
         seven=0;
         //真實情況沒可能達到該值,12MHZ的機器頻率才1MHZ
          }
      }
     }
    }
   }
}
////////////////////////////////////////////////////////////////////////////// counter

}//int0 counter  


void timer0() interrupt 1 using 1           //1s
{ uchar i;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
   i++;
if(i==20)//1s
{
i=0;
////////////////////////////////////////////////////////////////////////////// change gear
   if(seven!=0)
    { oneo=four;
     twoo=five;
     threeo=six;
     fouro=seven;
     dp4=0;
     dp3=0;
     dp2=0;
     dp1=1; //0000.   千位
    }
   else if(six!=0)
    { oneo=three;
     twoo=four;
     threeo=five;
     fouro=six;
     dp4=0;
     dp3=0;
     dp2=1;
     dp1=0; //000.0   百位
    }
   else if(five!=0)
    { oneo=two;
     twoo=three;
     threeo=four;
     fouro=five;
        dp4=0;
     dp3=1;
     dp2=0;
     dp1=0; //00.00   十位
    }
      else
    { oneo=one;
     twoo=two;
     threeo=three;
     fouro=four;                                          
     dp4=1;
     dp3=0;
     dp2=0;
     dp1=0; //0.000   個位
    }

////////////////////////////////////////////////////////////////////////////// change gear
one=0;
two=0;
three=0;
four=0;
five=0;
six=0;
seven=0;
////////////////////////////////////////////////////////////////////////////////////1s
}
}//timer0 1s

void timer1() interrupt 3 using 3    //display
{    uchar j;
TH1=(65536-6000)/256;
TL1=(65536-6000)%256;

      if(j<4)
       j++;
      else
        j=1;
    ///////////////////////////////////////
         if(j==1)
          {
      P1=display[oneo];
     DP=dp1;
            }
      else if(j==2)
             {
      P1=display[twoo];
     DP=dp2;
        }
          else if(j==3)
             {
      P1=display[threeo];
      DP=dp3;
       }
       else if(j==4)
             {
      P1=display[fouro];
         DP=dp4;
       }


////////////////////////////////////////////////select
   if(j==1)
    {P3_0=0;P3_1=1;P3_4=1;P3_5=1;}
   else if(j==2)
    {P3_0=1;P3_1=0;P3_4=1;P3_5=1;}
   else if(j==3)
    {P3_0=1;P3_1=1;P3_4=0;P3_5=1;}
   else if(j==4)
    {P3_0=1;P3_1=1;P3_4=1;P3_5=0;}
//////////////////////////////////////////////

}//timer1 display

回復

使用道具 舉報

ID:77387 發表于 2015-5-10 11:51 | 顯示全部樓層
不是太懂啊
回復

使用道具 舉報

ID:75172 發表于 2015-5-30 10:20 | 顯示全部樓層
無圖無真相啊
回復

使用道具 舉報

ID:73994 發表于 2015-5-31 10:08 | 顯示全部樓層
感覺很復雜的的  有點迷糊
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表