ADC0809

sonic   2010-6-14 10:45 楼主
哪位告诉我在ADC0809中disbuf[10,10,10,10,10,10,0,0]是做什么用的?转换来转换去实在是不知道他在干什么?

回复评论 (10)

问题没明白?
点赞  2010-6-14 12:58
看不明白问题!
你就放这一个东东在上面,谁看得懂是什么意思啊!
点赞  2010-6-14 14:11
upupupupupupupupupupupupupupupupupup
点赞  2010-6-14 20:12
根据楼主的描述应该是程序中的一段代码,所列出的应该是一个数组,这个要具体问题具体分析,建议楼主把代码贴出来,大家一起商量。。。
点赞  2010-6-14 21:21
单单一个数组.看不明白.
点赞  2010-6-15 09:10
代码会比较长,这是一个液位控制器的代码:
#include
unsigned char code dispbitcode[]={0x31,0x32,0x34,0x38,0x30,0x30,0x30,0x30};
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x77,0x7c,0x39};
unsigned char dispbuf[8]={10,10,10,10,10,10,0,0};
unsigned char dispcount;
unsigned char getdata;
unsigned int temp;
unsigned int temp1;
unsigned char i;
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^4;
sbit CLK=P3^5;
sbit M1=P3^6;
sbit M2=P3^7;
sbit SPK=P2^6;
sbit LA=P3^3;
sbit LB=P3^2;
sbit LC=P2^7;
sbit K1=P2^4;
sbit K2=P2^5;
bit wd;
bit yw;
bit shuid;
bit shuig;
unsigned int cnta;
unsigned int cntb;
bit alarmflag;
void delay10ms(void)
{
unsigned char i,j;
for(i=20;i>0;i--)

for(j=248;j>0;j--);
}
void main(void)
{
M1=0;
M2=0;
yw=1;
wd=0;
SPK=0;
ST=0;
OE=0;
TMOD=0x12;
TH0=0x216;
TL0=0x216;
TH1=(65536-500)/256;
TL1=(65536-500)%256;
TR1=1;
TR0=1;
ET0=1;
ET1=1;
EA=1;
ST=1;
ST=0;
while(1)
{
if(K1==0)
{
delay10ms();
if(K1==0)
{
yw=1;
wd=0;
}
}
else if(K2==0)
{
delay10ms();
if(K2==0)

{
wd=1;
yw=0;
}
}
else if(LC==1)
{
delay10ms();
if(LC==1)
{
M1=0;
M2=1;
temp1=13;
shuid=0;
shuig=1;
LB=0;
}
}
else if((LC==0) && (LB==1))
{
delay10ms();
if((LC==0) && (LB==1))
{
M1=0;
M2=0;
temp1=12;
shuig=0;
shuid=0;
LB=0;
}
}
else if ((LB==0) && (LA==1))
{
delay10ms();
if((LB==0) && (LA==1))
{
M1=1;
M2=0;

temp1=11;
shuig=0;
shuid=0;
LB=0;
}
}
else if (LA==0)
{
delay10ms();
if(LA==0)
{
M1=1;
M2=0;
temp1=0;
shuid=1;
shuig=0;
LB=0;
}
}
}
}
void t0(void) interrupt 1 using 0
{
CLK=~CLK;
}
void t1(void) interrupt 3 using 0
{
TH1=(65536-500)/256;
TL1=(65536-500)%256;
if(EOC==1)
{
OE=1;
getdata=P1;
OE=0;
temp=getdata*25;
temp=temp/64;

i=2;
dispbuf[0]=10;
dispbuf[1]=10;
dispbuf[2]=0;
dispbuf[3]=0;
if((yw==1)&&(wd==0))
{
dispbuf[++i]=temp1;
}
else if((yw==0)&&(wd==1))
{while(temp/10)
{
dispbuf=temp/10;
temp=temp%10;
}
dispbuf[++i]=temp;
}
ST=1;
ST=0;
}
P0=dispcode[dispbuf[dispcount]];
P2=dispbitcode[dispcount];
dispcount++;
if(dispcount==8)
{
dispcount=0;
}
if((shuig==1) && (shuid==0))
{
cnta++;
if(cnta==800)
{
cnta=0;
alarmflag=~alarmflag;
}
if(alarmflag==1)

{
SPK=~SPK;
}
}
else if((shuig==0) && (shuid==1))
{
cntb++;
if(cntb==400)
{
cntb=0;
alarmflag=~alarmflag;
}
if(alarmflag==1)
{
SPK=~SPK;
}
}
else
{
alarmflag=0;
cnta=0;
cntb=0;
}
}

点赞  2010-6-15 09:33
代码会比较长,这是一个液位控制器的代码:
#include
unsigned char code dispbitcode[]={0x31,0x32,0x34,0x38,0x30,0x30,0x30,0x30};
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x77,0x7c,0x39};
unsigned char dispbuf[8]={10,10,10,10,10,10,0,0};
unsigned char dispcount;
unsigned char getdata;
unsigned int temp;
unsigned int temp1;
unsigned char i;
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^4;
sbit CLK=P3^5;
sbit M1=P3^6;
sbit M2=P3^7;
sbit SPK=P2^6;
sbit LA=P3^3;
sbit LB=P3^2;
sbit LC=P2^7;
sbit K1=P2^4;
sbit K2=P2^5;
bit wd;
bit yw;
bit shuid;
bit shuig;
unsigned int cnta;
unsigned int cntb;
bit alarmflag;
void delay10ms(void)
{
unsigned char i,j;
for(i=20;i>0;i--)

for(j=248;j>0;j--);
}
void main(void)
{
M1=0;
M2=0;
yw=1;
wd=0;
SPK=0;
ST=0;
OE=0;
TMOD=0x12;
TH0=0x216;
TL0=0x216;
TH1=(65536-500)/256;
TL1=(65536-500)%256;
TR1=1;
TR0=1;
ET0=1;
ET1=1;
EA=1;
ST=1;
ST=0;
while(1)
{
if(K1==0)
{
delay10ms();
if(K1==0)
{
yw=1;
wd=0;
}
}
else if(K2==0)
{
delay10ms();
if(K2==0)

{
wd=1;
yw=0;
}
}
else if(LC==1)
{
delay10ms();
if(LC==1)
{
M1=0;
M2=1;
temp1=13;
shuid=0;
shuig=1;
LB=0;
}
}
else if((LC==0) && (LB==1))
{
delay10ms();
if((LC==0) && (LB==1))
{
M1=0;
M2=0;
temp1=12;
shuig=0;
shuid=0;
LB=0;
}
}
else if ((LB==0) && (LA==1))
{
delay10ms();
if((LB==0) && (LA==1))
{
M1=1;
M2=0;

temp1=11;
shuig=0;
shuid=0;
LB=0;
}
}
else if (LA==0)
{
delay10ms();
if(LA==0)
{
M1=1;
M2=0;
temp1=0;
shuid=1;
shuig=0;
LB=0;
}
}
}
}
void t0(void) interrupt 1 using 0
{
CLK=~CLK;
}
void t1(void) interrupt 3 using 0
{
TH1=(65536-500)/256;
TL1=(65536-500)%256;
if(EOC==1)
{
OE=1;
getdata=P1;
OE=0;
temp=getdata*25;
temp=temp/64;

i=2;
dispbuf[0]=10;
dispbuf[1]=10;
dispbuf[2]=0;
dispbuf[3]=0;
if((yw==1)&&(wd==0))
{
dispbuf[++i]=temp1;
}
else if((yw==0)&&(wd==1))
{while(temp/10)
{
dispbuf=temp/10;
temp=temp%10;
}
dispbuf[++i]=temp;
}
ST=1;
ST=0;
}
P0=dispcode[dispbuf[dispcount]];
P2=dispbitcode[dispcount];
dispcount++;
if(dispcount==8)
{
dispcount=0;
}
if((shuig==1) && (shuid==0))
{
cnta++;
if(cnta==800)
{
cnta=0;
alarmflag=~alarmflag;
}
if(alarmflag==1)

{
SPK=~SPK;
}
}
else if((shuig==0) && (shuid==1))
{
cntb++;
if(cntb==400)
{
cntb=0;
alarmflag=~alarmflag;
}
if(alarmflag==1)
{
SPK=~SPK;
}
}
else
{
alarmflag=0;
cnta=0;
cntb=0;
}
}

点赞  2010-6-15 09:34
//主要就是:
P0=dispcode[dispbuf[dispcount]];//dispcode[10]=00不亮
P2=dispbitcode[dispcount];
点赞  2010-6-15 10:16
查表显示
点赞  2010-6-15 13:58
好像与什么缓冲区有关!我在研究研究……
点赞  2010-6-17 18:41
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复