[an error occurred while processing this directive]
|
; ADC AD7890 support
;Start ADC
;A - channel number (A=1..8),
ADCST: CLR SCLK
CLR TFS ;transmit frame synchronization
MOV DPTR,#ADCTAB
MOVC A,@A+DPTR ;ADC channel
MOV R0,#8H ;bit counter load
ADCLD1: SETB SCLK
RLC A
MOV DIO,C
CLR SCLK
DJNZ R0,ADCLD1
SETB TFS ;transmit frame synchronization
SETB SCLK
SETB DIO
RET
ADCTAB .DB 00000000B
.DB 10110000B ;CH1, ADC channel 5
.DB 01110000B ;CH2, ADC channel 3
.DB 00110000B ;CH3, ADC channel 1
.DB 10010000B ;AM1, ADC channel 4
.DB 01010000B ;AM2, ADC channel 2
.DB 00010000B ;AM3, ADC channel 0
;Read ADC
;Output code - 2s complement binary
;R2 - address 0,0,0,0,0,A2,A1,A0
;R3 - low byte: D3,D2,D1,D0,0,0,0,0
;R4 - high byte: D11,D10,D9,D8,D7,D6,D5,D4
ADCRD: CLR RFS ;receive frame synchronization
CLR A
MOV R0,#4H ;bit counter load
ADCRD1: CLR SCLK
MOV C,DIO
RLC A
SETB SCLK
DJNZ R0,ADCRD1
MOV R2,A ;save address
MOV R0,#8H ;bit counter load
ADCRD2: CLR SCLK
MOV C,DIO
RLC A
SETB SCLK
DJNZ R0,ADCRD2
MOV R4,A ;save high byte
CLR A
MOV R0,#4H ;bit counter load
ADCRD3: CLR SCLK
MOV C,DIO
RLC A
SETB SCLK
DJNZ R0,ADCRD3
SWAP A
MOV R3,A ;save low byte
SETB RFS ;receive frame synchronization
SETB DIO
RET
E-mail: info@telesys.ru