Microprocessors and Microcontroller: Program: To Display Two Digits On A 7 Segment Displays
Microprocessors and Microcontroller: Program: To Display Two Digits On A 7 Segment Displays
The 1Hz frequency or 1 second time delay can be produced exactly by using
a timer 8253 or by using a well designed delay subroutine.
Program Logic
Three CPU registers are used to count Hours, Minutes and Seconds. The
Seconds counter is incremented for every second, and its content checked for 60.
When it reaches 60, it is reset to 0 and the Minutes counter is incremented by one.
When the Minutes counter reaches 60, it is reset to zero and the Hour counter is
incremented by one. Similarly, when the Hours counter reaches 13 it is reset to 1.
The counter incrementing is done in decimal format. For every second the display
is updated by the Hours, Minutes and Seconds registers. The program works in a
continuous loop and displays time round the clock. The block diagram of the
digital clock, the flow chart and the program are shown below.
Digital Clock Basic Block Diagram
8255
PB0-B3 7447
ADDRESS
DECODER CS’ PC4-C7
7447
Sec
A0-A7 PC0-C3
7447
FLOW CHART
START
INITIALIZE HR,MIN,SEC
COUNTERS
SEC SEC +1
SEC >59? Y
N
MIN MIN +1
SEC 0
Y
MIN >59?
N
HR HR +1
MIN 0
HR >12?
N
Y
HR1