開機計數(shù)器實驗
——
;24c02的開機計數(shù)器,系統(tǒng)復(fù)位一次數(shù)碼管加1
;**********************************
SDA24 EQU P1.4
SCLK24 EQU P1.5
ORG 0000H
AJMP MAIN
ORG 0030H
MAIN: MOV DPTR,#TAB
MOV A,#00H ;讀地址
LCALL RD24
CJNE A,#10,TT
TT: JNC TT1
AJMP TT2
TT1: MOV A,#00
TT2: MOV 30H,A
MOVC A,@A+DPTR
CLR P2.0 ;開數(shù)碼管
MOV P0,A ;送顯示
MOV A,30H
INC A
MOV B,A
MOV A,#00H
LCALL WT24
AJMP $
RD24: PUSH ACC ;讀24C02子程序。
SETB SDA24
CLR SCLK24
CALL START24
MOV A,#0A0H
CALL SHIFT8
CALL ACK
POP ACC
CALL SHIFT8
CALL ACK
CALL START24
MOV A,#0A1H
CALL SHIFT8
CALL ACK
SETB SDA24
MOV R7,#8
CLR A
SETB SDA24
RD000: RL A
SETB SCLK24
MOV C,SDA24
MOV ACC.0,C
CLR SCLK24
DJNZ R7,RD000
RET {{分頁}}
;寫入24C02程序:
WT24: PUSH ACC
SETB SDA24
CLR SCLK24
CALL START24
MOV A,#0A0H
CALL SHIFT8
CALL ACK
POP ACC
CALL SHIFT8
CALL ACK
MOV A,B
CALL SHIFT8
CALL ACK
CALL STOP
CALL DELAY2
RET
;開始條件
START24: CLR SDA24
SETB SDA24
SETB SCLK24
CLR SDA24
CLR SCLK24
RET
;停止條件
STOP: CLR SDA24
SETB SCLK24
SETB SDA24
RET
;應(yīng)答信號
ACK: SETB SCLK24
CLR SCLK24
RET
;讀、寫數(shù)據(jù)
SHIFT8: MOV R7,#8
SH01: RLC A
MOV SDA24,C
SETB SCLK24
CLR SCLK24
DJNZ R7,SH01
RET
DELAY2: NOP
NOP
NOP
NOP
RET
TAB: DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90H
END
塵埃粒子計數(shù)器相關(guān)文章:塵埃粒子計數(shù)器原理
評論