Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Seven Segment LED Interface

7segled

@ P. Klimo November 2005

Driving Eight Digit Seven Segment LED Display.

One Digit of a Seven Segment LED

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.

Seven Segment LED Interface

7segled

@ P. Klimo November 2005

Direct Drive of a Seven Segment Display.

Address Lines A0 A1 0 0 1 0 0 1 1 1

8255 Register Select Port A Port B Port C Control Register

8255 Port Address Select:

D4

D3

D1

D0

8255 Control Word

D0: D1: D3: D4:

Port C (lower) Port B Port C (upper) Port A

1 = input 1 = input 1 = input 1 = input

0 = output 0 = output 0 = output 0 = output

Seven Segment LED Interface

7segled

@ P. Klimo November 2005

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

Control Word = 10000000 = 80h

(As we are not using PortB we leave it configured as an output D1 = 0 )

Seven Segment LED Interface

7segled

@ P. Klimo November 2005

Example: Display the character 0 as a third l.s. digit.

Step 1:

Configure the ports A and C:

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

Action : Write the character code 3Eh into port Ch.

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.

Action : Write the digit 2 into the port Eh.

Seven Segment LED Interface

7segled

@ P. Klimo November 2005

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 :

b=c=1 obtained from 0011 0000 b

; 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

You might also like