找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1309|回复: 5
收起左侧

这个单片机频率计,为什么无法实现功能呢?

[复制链接]
ID:513931 发表于 2019-4-16 19:41 | 显示全部楼层 |阅读模式
T14BCLF_MUO5B}WFAS7}O%1.png
#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,0xa1,0x86,0x8e,0x00,0xbf};
uint a=0;
uint b=0;
uint c=0;
uchar day=0;
uchar ch=0;
uchar ch1=0;
uchar ch2=0;
uchar shi=0;
uchar shi1=0;
uchar shi2=0;
uchar fen=0;
uchar fen1=0;
uchar fen2=0;
uchar miao=0;
uchar miao1=0;
uchar miao2=0;
//延时
void DelayMS(uint x)
{
        uchar i;
        while(x--) for(i=0;i<120;i++);
}
void xianshi()
{
   while(1)                                 
   {  
   ch=ch%10;
   ch=ch/10;
   shi1=shi%10;
   shi2=shi/10;
   fen1=fen%10;
   fen2=fen/10;        
   miao1=miao%10;
   miao2=miao/10;
   P2=0x80;
   P0=DSY_CODE[miao1];
   DelayMS(5);
   P2=0x00;
   P2=0x40;
   P0=DSY_CODE[miao2];
   DelayMS(5);
   P2=0x00;
   P2=0x20;
   P0=DSY_CODE[fen1];
   DelayMS(5);
   P2=0x00;
   P2=0x10;
   P0=DSY_CODE[fen2];
   DelayMS(5);
   P2=0x00;
   P2=0x08;
   P0=DSY_CODE[shi1];
   DelayMS(5);
   P2=0x00;
   P2=0x04;
   P0=DSY_CODE[shi2];
   DelayMS(5);
   P2=0x00;                                
   P2=0x02;
   P0=DSY_CODE[ch1];
   DelayMS(5);
   P2=0x00;
   P2=0x01;
   P0=DSY_CODE[ch2];  
   DelayMS(5);
   P2=0x00;
   }
}
void main()
{
   TMOD=0x51;
   EA=1;
   ET0=1;
   ET1=1;
   TH0=(65536-50000)/256;
   TL0=(65536-50000)%256;
   TH1=0x00;
   TL1=0x00;

   TR0=1;
   TR1=1;
   while(1)
   {                 
          xianshi();
   }
}

void zhongduan1() interrupt 1
{   
    TH0=(65536-50000)/256;
    TL0=(65536-50000)%256;
    b++;  
        if(b==20)
        {  
           c=(day*65536+TH1*256+TL1);
           miao=c%100;
           fen=(c/100)%100;
           shi=(c/10000)%100;
           ch=c/1000000;
           b=0;
           TH1=0;
           TL1=0;
           TR1=0;
        }
               
}
void zhongduan2() interrupt 3
{
    day++;
}

回复

使用道具 举报

ID:337069 发表于 2019-4-17 10:06 | 显示全部楼层
0X51 T1脉冲计数器 要接到P3.5,
回复

使用道具 举报

ID:213173 发表于 2019-4-17 15:33 | 显示全部楼层
给你修改好了,你试试。
无标题.jpg

频率表+仿真.zip (60.32 KB, 下载次数: 6)
回复

使用道具 举报

ID:513931 发表于 2019-4-24 11:30 来自手机 | 显示全部楼层
wulin 发表于 2019-4-17 15:33
给你修改好了,你试试。

可以了 感谢
回复

使用道具 举报

ID:513931 发表于 2019-4-24 11:30 来自手机 | 显示全部楼层
chtyise 发表于 2019-4-17 10:06
0X51 T1脉冲计数器 要接到P3.5,

弄好啦 感谢
回复

使用道具 举报

ID:149799 发表于 2019-5-19 11:16 | 显示全部楼层
这个频率计,上限频率是多少。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表