[size=+1]C语言源程序
#include <AT89X52.H>
unsigned char code dispbitcode[]={0xfe,0xfd,0xfb,0xf7,
0xef,0xdf,0xbf,0x7f};
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f,0x00};
unsigned char dispbuf[8]={10,10,10,10,10,0,0,0};
unsigned char dispcount;
[size=+1]sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^2;
unsigned char channel=0xbc;//IN3
unsigned char getdata;
[size=+1]void main(void)
{
TMOD=0x01;
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
TR0=1;
ET0=1;
EA=1;
[size=+1]P3=channel;
[size=+1]while(1)
{
ST=0;
ST=1;
ST=0;
while(EOC==0);
OE=1;
getdata=P0;
OE=0;
dispbuf[2]=getdata/100;
getdata=getdata%10;
dispbuf[1]=getdata/10;
dispbuf[0]=getdata%10;
}
}
[size=+1]void t0(void) interrupt 1 using 0
{
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
P1=dispcode[dispbuf[dispcount]];
P2=dispbitcode[dispcount];
dispcount++;
if(dispcount==8)
{
dispcount=0;
}
}
请解释一下当选择第三通道时,为何是这句:unsigned char channel=0xbc;//IN3
在设置显示缓冲时为何是:unsigned char dispbuf[8]={10,10,10,10,10,0,0,0};
这是什么意思:
dispbuf[2]=getdata/100;
getdata=getdata%10;
dispbuf[1]=getdata/10;
dispbuf[0]=getdata%10;
为何如此写,请作一个详细的分析,我是单片机初学者,谢谢!
|