找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索

這個(gè)單片機(jī)頻率計(jì),為什么無(wú)法實(shí)現(xiàn)功能呢?

查看數(shù): 1814 | 評(píng)論數(shù): 5 | 收藏 1
關(guān)燈 | 提示:支持鍵盤翻頁(yè)<-左 右->
    組圖打開中,請(qǐng)稍候......
發(fā)布時(shí)間: 2019-4-16 19:41

正文摘要:

#include<reg51.h> #include<intrins.h> #define uchar unsigned char #define uint unsigned int uchar code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90, 0x88,0x83,0xc6, ...

回復(fù)

ID:149799 發(fā)表于 2019-5-19 11:16
這個(gè)頻率計(jì),上限頻率是多少。
ID:513931 發(fā)表于 2019-4-24 11:30
chtyise 發(fā)表于 2019-4-17 10:06
0X51 T1脈沖計(jì)數(shù)器 要接到P3.5,

弄好啦 感謝
ID:513931 發(fā)表于 2019-4-24 11:30
wulin 發(fā)表于 2019-4-17 15:33
給你修改好了,你試試。

可以了 感謝
ID:213173 發(fā)表于 2019-4-17 15:33
給你修改好了,你試試。


頻率表+仿真.zip (60.32 KB, 下載次數(shù): 6)


  1. #include<reg51.h>
  2. #include<intrins.h>
  3. #define uchar unsigned char
  4. #define uint unsigned int
  5. #define ulong unsigned long
  6. uchar code DSY_CODE[]={//共陽(yáng)數(shù)碼管段碼"0~f-."
  7.                 0xc0,0xf9,0xa4,0xb0,
  8.                 0x99,0x92,0x82,0xf8,
  9.                 0x80,0x90,0x88,0x83,
  10.                 0xc6,0xa1,0x86,0x8e,0xbf,0x7f};
  11. uchar code wei[]={0x01,0x02,0x04,0x08};
  12. uchar buf[4];//緩存
  13. uint bb=0;
  14. uint count=0;
  15. bit sign=0;

  16. void xianshi()
  17. {
  18.         static uchar i=0,j=0;        //計(jì)數(shù)變量
  19.         if(++j>=8)
  20.         {
  21.                 j=0;
  22.                 P0=0xff;                                        //消隱
  23.                 switch(i)
  24.                 {
  25.                         case 0: P2=wei[i];P0=DSY_CODE[buf[3]];i++;break;
  26.                         case 1: P2=wei[i];P0=DSY_CODE[buf[2]];i++;break;
  27.                         case 2: P2=wei[i];P0=DSY_CODE[buf[1]];i++;break;
  28.                         case 3: P2=wei[i];P0=DSY_CODE[buf[0]];i=0;break;
  29.            }
  30.         }
  31. }
  32. void main()
  33. {
  34.         uchar j;
  35.         TMOD= 0x52;                //設(shè)置定時(shí)器模式
  36.         TL0 = 0x06;                //設(shè)置定時(shí)初值,晶振12MHz
  37.         TH0 = 0x06;                //設(shè)置定時(shí)重載值
  38.         TH1=0x00;
  39.         TL1=0x00;
  40.         TR0=1;
  41.         TR1=1;
  42.         EA=1;
  43.         ET0=1;
  44.         while(1)
  45.         {                 
  46.                 if(sign==1)
  47.                 {
  48.                         sign=0;
  49.                         for(j=0;j<4;j++)//分解數(shù)據(jù)
  50.                         {
  51.                                 buf[j]=count%10;//按位保存
  52.                                 count/=10;
  53.                         }
  54.                 }
  55.         }
  56. }

  57. void zhongduan1() interrupt 1
  58. {   
  59.         bb++;  
  60.         if(bb==4000)
  61.         {  
  62.                 bb=0;
  63.                 sign=1;
  64.                 count=TH1;
  65.                 count=(count<<8)+TL1;
  66.                 TH1=0;
  67.                 TL1=0;
  68.         }
  69.         xianshi();
  70. }
復(fù)制代碼




ID:337069 發(fā)表于 2019-4-17 10:06
0X51 T1脈沖計(jì)數(shù)器 要接到P3.5,

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

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表