微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ADC0809AD转换器基本应用技术

ADC0809AD转换器基本应用技术

时间:04-02 来源:互联网 点击:

,LOP

MOV @R0,#00H

INC R0

MOV @R0,#00H

INC R0

MOV @R0,#00H

MOV TMOD,#01H

MOV TH0,#(65536-4000)/256

MOV TL0,#(65536-4000) MOD 256

SETB TR0

SETB ET0

SETB EA

WT: CLR ST

SETB ST

CLR ST

WAIT: JNB EOC,WAIT

SETB OE

MOV GDATA,P0

CLR OE

MOV A,GDATA

MOV B,#100

div AB

MOV 33H,A

MOV A,B

MOV B,#10

div AB

MOV 34H,A

MOV 35H,B

SJMP WT

T0X: NOP

MOV TH0,#(65536-4000)/256

MOV TL0,#(65536-4000) MOD 256

MOV DPTR,#DPCD

MOV A,DPCNT

ADD A,#DPBUF

MOV R0,A

MOV A,@R0

MOVC A,@A+DPTR

MOV P1,A

MOV DPTR,#DPBT

MOV A,DPCNT

MOVC A,@A+DPTR

MOV P2,A

INC DPCNT

MOV A,DPCNT

CJNE A,#8,NEXT

MOV DPCNT,#00H

NEXT: RETI

DPCD: DB 3FH,06H,5BH,4FH,66H

DB 6DH,7DH,07H,7FH,6FH,00H

DPBT: DB 0FEH,0FDH,0FBH,0F7H

DB 0EFH,0DFH,0BFH,07FH

END

8. 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;

sbit ST=P3^0;

sbit OE=P3^1;

sbit EOC=P3^2;

unsigned char channel=0xbc;//IN3

unsigned char getdata;

void main(void)

{

TMOD=0x01;

TH0=(65536-4000)/256;

TL0=(65536-4000)%256;

TR0=1;

ET0=1;

EA=1;

P3=channel;

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;

}

}

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;

}

}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top