|
|
|
;------------------------------------------------
inicio:
;------------------------------------------------
call setup
call ADC_ch0
call ADC_ch1
jmp inicio
;------------------------------------------------
ADC_ch0:
;------------------------------------------------
clr P1.0 ;despierta chip
setb P1.3 ;startbit=1
call delay
call clock
setb P1.3 ;modo=simple
call delay
call clock
clr P1.3 ;ch0
call delay
call clock
call read_ch
setb P1.0 ;duerme chip
ret
;------------------------------------------------
ADC_ch1:
;------------------------------------------------
clr P1.0 ;despierta chip
setb P1.3 ;startbit=1
call delay
call clock
setb P1.3 ;modo=simple
call delay
call clock
setb P1.3 ;ch1
call delay
call clock
call read_ch
setb P1.0 ;duerme chip
ret
;------------------------------------------------
read_ch:
;------------------------------------------------
mov r3,#7
leer_ch:
call delay
call clock ;empieza lectura
jnb p1.2,leer
inc A
leer rl A
djnz r3,leer_ch
mov R4,A
clr A
ret
;------------------------------------------------
Clock:
;------------------------------------------------
setb P1.1
call delay
clr P1.1
ret
;------------------------------------------------
Setup:
;------------------------------------------------
MOV SCON,#01000000B
MOV TMOD,#00100001B
MOV TH1,#0FDH
MOV TL1,#0FDH
SETB TR1
CLR TI
MOV SBUF,#00000000b
JNB TI,$
CLR TI
;------------------------------------------------
demora:
;------------------------------------------------
; ret
MOV R0,#0FFh
;demo1 MOV R2,#020h
demo0 DJNZ R0,demo0
; DJNZ R1,demo1
RET
;------------------------------------------------
delay:
;------------------------------------------------
mov TH0,#high(-3000)
mov TL0,#low(-3000)
setb TR0
flag: jnb TF0,flag
clr TR0
clr TF0
ret
end
|
|
|
|
|
|
|