các bác xem giúp đoạn code đọc adc 0808 cua em với, saoem mô phỏng protues ko dc.
ORG 0000H
SETB P3.1
MOV P1,#0FFH
MOV TMOD,#02H
MAIN:
;ACALL CONGVAO
BATDAU:
ACALL START
ACALL LAYDATA
LJMP BATDAU
//******************
/*CONGVAO:
CLR P0.0
CLR P0.1
CLR P0.2*/
//****************
;QUA TRINH BIEN DOI SE THUC HIEN KHI CO CANH XUONG TREN CHAN START
START:
SETB P3.0; cap xung chan start va ale cua adc0808
NOP
NOP
NOP
CLR P3.0
ACALL DELAY_100us ; DOI DE QUA TRINH CHUYEN DOI XONG
RET
LAYDATA:
NOP
HERE:
JB P3.1,HERE ; kiem tra chan OEC cua adc
SETB P3.2 ; cho phep dua du lieu ra cong ra cua adc
NOP
NOP
MOV A,P1
MOV P2,A
RET
DELAY_100us:
MOV TH0,#78H
SETB TR0
HERE1:
JNB TF0,HERE1
CLR TR0
CLR TF0
RET
END
ORG 0000H
SETB P3.1
MOV P1,#0FFH
MOV TMOD,#02H
MAIN:
;ACALL CONGVAO
BATDAU:
ACALL START
ACALL LAYDATA
LJMP BATDAU
//******************
/*CONGVAO:
CLR P0.0
CLR P0.1
CLR P0.2*/
//****************
;QUA TRINH BIEN DOI SE THUC HIEN KHI CO CANH XUONG TREN CHAN START
START:
SETB P3.0; cap xung chan start va ale cua adc0808
NOP
NOP
NOP
CLR P3.0
ACALL DELAY_100us ; DOI DE QUA TRINH CHUYEN DOI XONG
RET
LAYDATA:
NOP
HERE:
JB P3.1,HERE ; kiem tra chan OEC cua adc
SETB P3.2 ; cho phep dua du lieu ra cong ra cua adc
NOP
NOP
MOV A,P1
MOV P2,A
RET
DELAY_100us:
MOV TH0,#78H
SETB TR0
HERE1:
JNB TF0,HERE1
CLR TR0
CLR TF0
RET
END