当前位置:首页 > 单片机 > 单片机
[导读]下面是我编的读icl7135的源程序,是串行接法,晶振6M,icl7135是种频是从单片机ALE端引出后四分之一分频得到的频率.#include #include #define uchar unsigned char #define unit unsigned int sbit p32=P3^2; uch

下面是我编的读icl7135的源程序,是串行接法,晶振6M,icl7135是种频是从单片机ALE端引出后四分之一分频得到的频率.

#include
#include
#define uchar unsigned char
#define unit unsigned int
sbit p32=P3^2;
uchar code dispbit[]={0xfe,0xfd,0xfb,0xf7,0xef}; // 定义位选
uchar code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//定义段码
uchar dispbuf[5]={0,0,0,0,0,}; //显示缓冲
uchar dispcount,t;
unit x,y;
bit flag;
void main()
{
TMOD=0x9;
TH0=0;
TL0=0;
TR0=1;
ET0=1;
IT0=1;
EX0=1;
EA=1;
while(1)
{
x=y;
dispbuf[4]=x/10000;
x=x%10000;
dispbuf[3]=x/1000;
x=x%1000;
dispbuf[2]=x/100;
x=x%100;
dispbuf[1]=x/10;
x=x%10;
dispbuf[0]=x;
P0=dispcode[dispbuf[dispcount]];
P2=dispbit[dispcount];
dispcount++;
if(dispcount==4)
{
dispcount=0;
}
for(t=0;t<50;t++);
}
}

void int0(void) interrupt 0
{
if(flag==0)
{
flag=1;
TH0=0;
TL0=0;
TR0=1;
}
else
{
flag=0;
TR0=0;
y=TH0*256+TL0;
y=y-10001;
TH0=0;
TL0=0;
}
}

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭