Sie sind auf Seite 1von 3

ORG 0000H MOV P1,#00H MOV P2,#00H SETB P3.

0 MOV P1,#00H MOV A,#38H LCALL COMM MOV A,#0EH LCALL COMM MOV A,#01H LCALL COMM MOV A,#80H LCALL COMM L5: MOV R2,#00H MOV R3,#00H lcall delay MOV TMOD,#01H MOV TH0,#0D8H MOV TL0,#0F0H CLR TF0 L0: till it JB P3.0,L0 lcall delay SETB TR0 ;start the timer0 ;set TMOD register to use in mode 1 ;set timer(0) higher nibble ;set timer(0) lower nibble ;clear timer overflow flag ;continue check the port p3.0 un is zero ; P1 LCD DATA ; P2 LCD CONTROL ; DETECTOR ; ; ; ; ; ; ; initialise LCD write command LCD on and cursor on clear LCD cursor on first line ; initialize register ;initialize register

L2: JNB TF0, L1 f it is heck port p3.0 CJNE R2,#99D,L3 inc R3 by 1 MOV R2,#00H MOV A,R3 ADD A,#01H DA A MOV R3,A SJMP L4 MOV A,R2 ADD A,#01H DA A

;check the timer overflow bit. I set continue otherwise c ;R2=!99 inc R2 (or) R2==99 clr R2 ,

L3:

;inc R2 untill it becomes 99

MOV R2,A L4: CLR TF0 MOV TH0,#0D8H MOV TL0,#0F0H SETB TR0 SJMP L2

L1: nue

JNB P3.0,L2 MOV A,#80H LCALL COMM MOV A,R3 ANL A,#0F0H SWAP A ORL A,#30H LCALL DATA1 MOV A,#81H LCALL COMM MOV A,R3 ANL A,#0FH ORL A,#30H LCALL DATA1 MOV A,#82H LCALL COMM MOV A,R2 ANL A,#0F0H SWAP A ORL A,#30H LCALL DATA1 MOV A,#83H LCALL COMM MOV A,R2 ANL A,#0FH ORL A,#30H LCALL DATA1 LJMP L5

;check the port p3.0 If it is set conti Otherwise check the timer overflow flag ; cursor on first line

ORG 0400H DATA1: LCALL READY MOV P1,A SETB P2.0 CLR P2.1 SETB P2.2 NOP NOP CLR P2.2 RET ORG 0450H COMM: LCALL READY MOV P1,A CLR P2.0 CLR P2.1 SETB P2.2 NOP NOP CLR P2.2 RET ORG 0500H READY: SETB P1.7 CLR P2.0 SETB P2.1 BACK: CLR P2.2 NOP NOP SETB P2.2 JB P1.7,BACK RET ORG 0550H Delay: MOV R5,#02h LOOP6: MOV R6,#50 LOOP5: MOV R7,#50 LOOP4: NOP NOP DJNZ R7,LOOP4 DJNZ R6,LOOP5 DJNZ R5,LOOP6 RET END

Das könnte Ihnen auch gefallen