You are on page 1of 12

Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Introduction:

This demo gives an idea about interfacing multiplexed seven segment display with seven segment
data input. The interfacing can be verified using a 4 digit counter program which will counts from
H’0000 to H’FFFF.

Demo Hardware:

4 digits of seven segment LED displays are connected in multiplexed mode with seven segment
data input.

Connect P0 to the seven segments sequentially and the Port lines P30, P31, P32 and P33 to the
digit selection lines.

www.MightyMicons.com 1
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
+5V

C1 0.1uF

C2 0.1uF

+5V +5V +5V +5V

7
23
4 3 2 1
Circuit Connection:

1
3
5
9
U20A U20B U20C U20D

VCC
IVCC
R29 R30 R31 R32

www.MightyMicons.com
74LS07 74LS07 74LS07 74LS07
JP1 16
P45/INT0
10K 10K 10K 10K

www.MightyMicons.com
22

2
4
6
8

P30/CNTR0

1
2
3
T1 T2 T3 T4
C NC 20 BC 557 BC 557 BC 557 BC 557
C3 33PF 6 P31/TZOUT 1K R33 1K R34 1K R35 1K R36
XIN/P46 18
XTAL1 P32/INT2/CNTR1 U8 U9 U10 U11
17

3
8
3
8
3
8
3
8

P33/INT3/TCIN
20MHZ 1

C
C
C
C
C
C
C
C

P37/TXD10/RXD1
C4 33PF 4 A 7 A 7 A 7 A 7
XOUT/P 47 6 A 6 A 6 A 6 A
B B B B
B B B B
C NC 32 C 4 C 4 C 4 C 4
P00/AN7/TXD11 C C C C
D 2 D 2 D 2 D 2

1
2
3
KLS 563 G
KLS 563 G
KLS 563 G
KLS 563 G

+5V 31 1 D 1 D 1 D 1 D
E E E E
P01/AN6 9 E 9 E 9 E 9 E
F F F F
F F F F
JP2 30 G 10 G 10 G 10 G 10
P02/AN5 G G G G
D.P 5 D.P 5 D.P 5 D.P 5
R2 29 D.P D.P D.P D.P
4K7 P03/AN4
PROGRAM 27
28 P04/AN3
1 MO DE 26
JP4 2 P05/AN2 +5V
3 2 25
+5V CNVSS P06/AN1
NORMAL
R1 4K7 24
P07/AN0
1
20

D1
R1 IN4148 15
DIR

a
VCC

P10/KI0
10K 2 18 R37 56E A
A1 B1
14 b
P11/KI1
U2 3 17 R38 56E B
1 2 3 4 3 13 A2 B2
RESET P12/KI2 c
4 16 R39 56E C
A3 B3
12 d
CD40106 P13/KI3 5 15 R40 56E
CD40106 D
SW 1 11 A4 B4
U2 e
P14/TXD0 6 14 R41 56E
+ E
+5V 10 A5 B5
P15/RXD0 f
C6 +5V 7 13 R42 56E F
RESET 4.7uF 9 +5V A6 B6
1 P16/CLK0 g
19 8 12 R43 56E G
JP3 2 AVCC/VREF 8 A7 B7
3 P17/INT1/CNTR0 h
R48 9 11 R44 56E D.P
A8 B8
EX
+5V 10K

AVSS
VSS
G
G ND

JP6

5
1 2

21
19
10

Note: Dotted lines indicate the required U1 R8C11/13 3 4 BCD


connections m eant for the application.
R53

1K

2
4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Connections:

Port lines Display Lines


P00 Segment a
P01 Segment b
P02 Segment c
P03 Segment d
P04 Segment e
P05 Segment f
P06 Segment g
P07 Segment dp

P30 Digit Selection Control for digit 1


P31 Digit Selection Control for digit 2
P32 Digit Selection Control for digit 3
P33 Digit Selection Control for digit 4

Functional Description:

In this demo, a four digit counter program is provided to study the interfacing of seven segment
display in multiplexed mode with seven segment data input. The 4 digit counter will be displayed
on the display counting from H’0000 to H’FFFF.

Registers Used:

PD0 - Port 0 Direction Register


PD3 - Port 3 Direction Register
TXMR - Timer X mode Register
PREX - Prescaler X Register
TX - Timer X Register
TCSS - Timer Count Source Setting Register

www.MightyMicons.com 3
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Port Direction Register:

PD0 is set to H’FF to select all lines of port 0 (P00 to P07) as output lines to control seven
segment display. Port lines P30 to P33 are set as output lines by moving data H’0F to PD3
register.

TXMR - Timer X Mode Register:

www.MightyMicons.com 4
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Timer X mode register TXMR is loaded with H’00 to set timer mode.

PREX -Prescaler X Register:

The prescaler register PREX is loaded with 100 to divide the input selected clock to timer X by
100.

TX - Timer X Register:

The timer X register TX loaded with 100 to generate an interrupt at 1 milli second rate.

www.MightyMicons.com 5
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

TCSS - Timer Count Source Setting Register:

The data H’03 is moved to Timer Count Source Setting Register TCSS to select “f2” as source
clock for Timer X.

Software Description:

In this demo, a four digit counter program is provided to study the interfacing of seven segment
display in multiplexed mode with seven segment data input.

Timer X is used to generate an interrupt at a rate of one milli second. In the timer X interrupt
service routine, the seven segment display is refreshed and the milli seconds are counted to get
one second delay. This milli second counter is used in main loop to get 1 second delay.

In the main loop, the timer X is initialized to generate interrupt at 1KHZ rate to refresh the display
and wait for one second. After a second, the count value is increment by one and displayed on
the 4 digit display. The process is repeated.

www.MightyMicons.com 6
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

The files used in this demo are listed below:

Files Description
The only file for this module, has the
processing function for the 4 digit counter ,
Demo2.C timer X interrupt service routine and
initialization routines for seven segment
display, timer X etc.

The functions in the file Demo2.C and short descriptions are listed below:

Files Description

A 4 digit counter which will counts from H'0000


to H'FFFF.
main
Input: None.
Output : None.

Timer X interrupt service routine. Here the seven


segment display was refreshed and the milli
LEDInterrupt seconds are counted to get one second delay.
Input: None.
Output : None.

Timer X is initialized to generate an interrupt at a


rate of one milli second.Timer X and variables
InitLEDDisplay used for refreshing display.
Input: None.
Output : None.

Files
This routine will initialize I/O lines used for seven
segment display,
Initialize7SegmentMuxDisplay
Input: None.
Output : None.

Displays the given 4 digit number on seven


segment display.
Display4Digits
Input: 4 Digit number.
Output : None.

www.MightyMicons.com 7
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Program Flow:
For Main Loop

Start

1 . In itia lize P o r t 0 a s
output port and port
line P 30 to P 33 as
o u tp u t lin e s . In itia lize
variables to 0.
2 . In itia lize T im e r X to
g e n e ra te a n in te rru p t
at 1 m sec rate.

Check m illi < 999


second count with
999

> 999

In c re m e nt th e c o u n t
a n d dis p la y it o n
LED display.

www.MightyMicons.com 8
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

For Timer X Interrupt Service Routine

Start

Get the lower 2 bits


of digit selection
variable (MuxData).
(Only 4 digits)

Switch off all the


digits

Send the 7-segm ent data


to port 0 and digit
selection data for
currently selected digit to
port 3.

Increm ent the currently


selected digit
variable.(MuxData)

Increm ent m illi second


count

Return from Interrupt

Execute Demo:

After reset, the 4 digit counter will be displayed on the display counting from H’0000 to H’FFFF.

www.MightyMicons.com 9
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Use Topview Simulator to Verify the Design.

Open the project Demo2 in the R8C/Tiny System Simulator using Open Project option from
Project menu. The project window opens up along with the Demo2.c file. Use Build option from
Build menu to compile the project. An output window captures the compiler ouput.

Use Project -> Download Project from main menu to download the Demo2.mot file into the
simulator’s memory for simulation.

www.MightyMicons.com 10
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Open the LED Module settings window and do the settings to the 7-segment LED module as
shown. Connect 7 segments of the display to the port lines P00 to P07 and the 4 digit selection
lines to P30, P31, P32 and P33 respectively using radio buttons.

www.MightyMicons.com 11
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P
Demo 2 - 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

Then open the LED window usign the option View -> External Modules -> LED as shown
below and the Program Window.

Run the program using Go from the Run menu. The program will display a 4 digit counter in the
7-segment display and counts from H’0000 to H’FFFF and it is repeated.

www.MightyMicons.com 12
www.MightyMicons.com 4 Digit Multiplexed 7-Segment Display With 7 Segment I/P

You might also like