Writing two-digit number on LED display
It is time for time multiplexing! This is the simplest example which displays the number 23 on two displays in such a way that one of them displays units, while the other displays tens. The most important thing in the program is time synchronization. Otherwise, everything is very simple. Transistor T4 enables display D4 and at the same time a bit combination corresponding to the digit 3 is set on the port. After that, transistor T4 is disabled and the whole process is repeated using transistor T3 and display D3 in order to display digit 2. This procedure must be continuosly repeated in order to make impression that both displays are active at the same time.;************************************************************************ ;* PROGRAM NAME: 7Seg3.ASM ;* DESCRIPTION: Program displays number "23" on 7-segment LED display ;************************************************************************ ;BASIC DIRECTIVES $MOD53 $TITLE(7SEG3.ASM) $PAGEWIDTH(132) $DEBUG $OBJECT $NOPAGING ;STACK DSEG AT 03FH STACK_START: DS 040H ;RESET VECTORS CSEG AT 0 JMP XRESET ; Reset vector ORG 100H XRESET: MOV SP,#STACK_START ; Define Stack pointer LOOP: MOV P1,#0 ; Turn off all display segments MOV P3,#20h ; Activate display D4 MOV A,#03 ; Write digit 3 on display D4 LCALL Disp ; Find appropriate mask for that digit MOV P1,A ; Put the mask on the port MOV P1,#0 ; Turn off all dislay segments MOV P3,#10h ; Activate display D3 MOV A,#02 ; Write digit 2 on display D3 LCALL Disp ; Find mask for that digit MOV P1,A ; Put the mask on the port SJMP LOOP ; Return to the label LOOP Disp: ; Subroutine for writing digits INC A MOVC A,@A+PC RET DB 3FH ; Digit 0 mask DB 06H ; Digit 1 mask DB 5BH ; Digit 2 mask DB 4FH ; Digit 3 mask DB 66H ; Digit 4 mask DB 6DH ; Digit 5 mask DB 7DH ; Digit 6 mask DB 07H ; Digit 7 mask DB 7FH ; Digit 8 mask DB 6FH ; Digit 9 mask END ; End of program