0% found this document useful (0 votes)
28 views

Counter Sensor 4 Digit

This document describes a 4-digit program counter sensor. It contains code to increment the counter, convert the counter value to BCD, display it on a 7-segment display, and delay between display updates. The main routine initializes ports and interrupts, then calls subroutines to convert the counter value, display it, and delay before repeating the process indefinitely.

Uploaded by

Ali Al Misbah
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Counter Sensor 4 Digit

This document describes a 4-digit program counter sensor. It contains code to increment the counter, convert the counter value to BCD, display it on a 7-segment display, and delay between display updates. The main routine initializes ports and interrupts, then calls subroutines to convert the counter value, display it, and delay before repeating the process indefinitely.

Uploaded by

Ali Al Misbah
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Program Counter Sensor 4 Digit

www.guidecircuit.com Date: 19-Dec-2007 ORG 0000H LJMP MAIN ORG 0013H COUNTER: PUSH ACC JB P3.4,B2 INC R3 MOV A,R3 ADD A#00 DA A MOV R3,A CJNE R3#00H B1 INC R2 MOV A,R2 ADD A,#00 DA A MOV R2,A B1:POP ACC RETI B2: CJNE R3,#00H,B3 MOV A,#99H CLR 00H SJMP B5 B3: DEC R3 MOV A,R3 ANL A,#0FH CJNE A,R3 B4: MOV A,R3 JC B5 ADD A,#0AH SUBB A,#10H B5: MOV R3,A CJNE A,#99H,B9 JB 00H,B6 CJNE R2,#00H,B6 MOV A,#99H SJMP B8 CONVERT: PUSH 01 PUSH 00 MOV R0#08 MOV R1,#08 A3: MOV A,@R0 SWAP A LCALL HEX_7SEG MOV @R1,A INC R1 MOV A,@R0 LCALL HEX_7SEG MOV @R1,A INC R1 INC R0 CJNE R1,#0CH,A3 POP 00 POP 01 RET HEX_7SEG: PUSH DPH PUSH DPL ANL A,#0FH MOV DPTR,#TABLE MOVC A,@A+DPTR POP DPL POP DPH RET TABLE:DB 3FH,06H,5BH,4FH,66H DB 6DH,7DH,07H,7FH,6FH DISPLAY: PUSH 00 PUSH 01 MOV R0,#08 MOV P1,@R0 CLR P3.7 LCALL DELAR

B6: DEC R2 MOV A,R2 ANL A,#0FH CJNE A,#0FH,,B7 B7: MOV A,R2 JC B8 ADD A,#0AH SUBB A,#10H B8: MOV R2,A B9: CJBE R2,#01H,B10 SETB A,#10H B10:POP ACC RETI MAIN:MOV SP,#30H MOV P1,#100000000H MOV P3,#11111111H MOV IE,#10000100B SETB IT1 CLR 00H A1:MOV R3,#00 MOV R2,#00 A2: LCALL CONVERT LCALL DISPLAY SETB P1,7 JNB P1,7,A1 SJMP A2

INC R0 SETB P3.0 MOV P1,@R0 CLR P3.7 LCALL DELAY INC R0 SETB P3.7 MOV P1,@R0 CLR P3.1 LCALL DELAY INC R0 SETB P3.1 MOV P1,@R0 CLR P3.2 LCALL DELAY SETB P3.2 MOV P1,#80H POP 01 POP 00 RET DELAY: MOV R4,#00H DJNZ R4,$ RET END

You might also like