AD574A reference program

Ad574a program:

Sbit ad_status = P3^3;

Uchar xdata ad_co nvert _at_ 0 x6000; //start conversion

Uchar xdata ad_read_hi _at_ 0 x6002; //read high byte

Uchar xdata ad_read_lo _at_ 0 x6003; //read low byte

Uint ad_1674 (void)

{

Unio n adc

{

Uint adCC;

Uchar ad[2];

};

Unin n adc add;

Ad_co nvert=0 xff;

While(ad_status);

Add.ad[0]=ad_read_hi;

Add.ad[1] =ad_read_lo;

Add.adcc=add.adcc>>4;

Return add.adcc;

}ORG 0000H

AJMP MAIN; main program

ORG 0013H

LJMP XAD; interrupt 1 A/D sampling subroutine

;*********************************************

;* Initialize the ad574a program*

;*********************************************

ORG 0030H

MAIN: MOV SP, #60H ; set stack

;SETB EA

Clr ie1

SETB IT1

START: LCALL MNLCJ

;*****************************************

;* A/D sampling subroutine initialization*

;*****************************************

AD1: PUSH DPH

PUSH DPL

PUSH ACC

MOV DPTR, #0C000H; open 0 channel

MOV A, #08H

MOVX @DPTR,A

MOV DPTR, #9000H ; start A/D conversion

MOVX @DPTR,A

SETB EX1

POP ACC

POP DPL

POP DPH

RET

;*****************************

;* A/D 574 interrupt subroutine*

;*****************************

XAD: PUSH DPH

PUSH DPL

PUSH ACC

MOV DPTR, #9002H; read high 8 results into 50H

MOVX A, @DPTR

MOV 50H, A

INC DPTR

MOVX A, @DPTR ; read in the lower 4 digits and put in 51H

MOV 51H, A

CLR EX1

POP ACC

POP DPL

POP DPH

RETI

;*********************************************

Analog acquisition*

;*********************************************

MNLCJ: MOV R0, #40H

LCALL AD1; first port analog acquisition

Ajmp $

; MOV A, 50H

; MOV @R0,A

;INC R0

;MOV A,51H

;MOV @R0,A

END

NOP

NOP

LJMP main

Chetak Gensets Set

Inverter Generator,Chetak Gensets Set,Diesel Silent Generator,Silent Diesel Generator

Wuxi Doton Power , http://www.dotonpower.com