Professional Documents
Culture Documents
Driving Eight Digit Seven Segment LED Display
Driving Eight Digit Seven Segment LED Display
7segled
Note: There are seven LEDs used to display a character or a digit. Each LED anode is connected to an external pin.
Each Seven Segment LED has a common cathode (not shown) connected to an external pin. An 8 digit display consists of eight identical seven segment LEDs, which will be time multiplexed.
The time multiplex involves (a) anodes connected in parallel (b) cathodes select the digit to be displayed The codes for the characters to be displayed can be stored in a character generator (i.e. a PROM) or a special MSI encoder/drivers can be used.
7segled
Address Lines A0 A1 0 0 1 0 0 1 1 1
D4
D3
D1
D0
7segled
Note: A single character is displayed by writing : (a) the character code to the PORTA and (b) the digit order into the PORTC The Chip Select pin of the 8255 is asserted when A2 and A3 address lines are high. The Base Address of the 8255 is 1100 = Ch so the ports have the following addreses:
Port A B C Control
Address Ch Dh Eh Fh
Before displaying a character the ports have to be configured as : All pins of PORTA as outputs All pins of PORTC as outputs 8255 ports are configured by writing a configuration word into the control register.
Control Word for the required configuration: PortA output : PortC output: D4 = 0 D0 = D3 = 0
7segled
Step 1:
Action: Write the configuration word 80h into the port Fh.
Step 2:
Write to port A the binary code for the character to be displayed: Character 0 requires a = b = c = d = e = f = 1 g=0 character code for 0 is 1 1 1 1 1 1 0 = 3Eh
Step 3:
Assert (low) the third digit cathode C3 . This requires the Y2 output of the 74LS138 eight to one decoder to be driven low.
7segled
Assembly Code: ;******************************************************** ; The Definitions PORTA PORTC CTRL CONFIG ZERO EQU EQU EQU EQU EQU Ch Eh Fh 80h 3Eh ; Port A address ; Port C address ; Control Port address ; Configuration Word( PortA and ; PortC are both outputs) ; Binary code to display 0
;********************************************************* ;********************************************************* ; THE CODE ; Configure the 8255 MOV AL, CONFIG OUT CTRL, AL Select appropriate LEDs anodes to represent the required digit (i.e. 0) MOV AL, ZERO OUT PORTA, AL Display it as the third digit MOV AL, 02 OUT PORTC, AL
; ;
Note: We could store the codes for hexadecimal digits in a table i.e. DIGIT DB DB DB 3Eh ; digit 0 30h ; digit 1 :
; and the remaining digits between 2 and ; between 2 and E until the last digit: 31h ; digit F: a = b= c = g = 1 1110001 = 31h
and use the indexed register addressing to get the relevant character code, e.g.: MOV SI, 10 ; select the hexadecimal character for 10 MOV AL, DIGIT[SI] ; and move it into AL
5