新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)實(shí)現(xiàn)adc0808程序

單片機(jī)實(shí)現(xiàn)adc0808程序

作者: 時(shí)間:2016-11-18 來(lái)源:網(wǎng)絡(luò) 收藏
一:系統(tǒng)圖:

本文引用地址:http://m.butianyuan.cn/article/201611/315684.htm

程序部分:

#include
unsigned char code dispbitcode[]={0x01,0x02,0x04,
0x08,0x10,0x20,0x40,0x80};
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char dispbuf[3]={0,0,0};
unsigned char dispcount;
sbit ST=P3^2;
sbit OE=P3^0;
sbit EOC=P3^1;
unsigned char getdata;
void main(void)
{
TMOD=0x01;
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
TR0=1;
ET0=1;
EA=1;
P3_4=1;
P3_5=1;
P3_6=0;
while(1)
{
ST=0;
ST=1;
ST=0;
while(EOC==0);
OE=1;
getdata=P1;
OE=0;
dispbuf[2]=getdata/100;
dispbuf[1]=getdata%10/10;
dispbuf[0]=getdata%10;
}
}
void t0(void) interrupt 1 using 0
{static unsigned int nn;
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
P2_0=0;
P0=dispcode[dispbuf[2]];
P2_0=1;
for(nn=0;nn<1000;nn++);
P2_1=0;
P0=dispcode[dispbuf[1]];
P2_1=1;
for(nn=0;nn<1000;nn++);
P2_2=0;
P0=dispcode[dispbuf[0]];
P2_2=1;
for(nn=0;nn<1000;nn++);
}



關(guān)鍵詞: 單片機(jī)adc0808程

評(píng)論


技術(shù)專區(qū)

關(guān)閉