Hardware Reference
In-Depth Information
#0
#1
#5
800
Ω
a
b
a
b
. . .
. . .
a
b
.
.
.
.
.
.
g
g
800 Ω
g
. . .
74HC244
Common
cathode
Common
cathode
Common
cathode
74HC367
PP0
A0
Y0
PP1
A1
Y1
PP2
A2
Y2
.
.
.
HCS12
PP3
A3
Y3
PP4
A4
Y4
PP5
A5
Y5
Figure 4.18 Port B and port P together drive six seven-segment displays (MC9S12DG256)
The instruction sequence is as follows:
#include
“c:\miniide\hcs12.inc”
seven
equ
$07
movb
#$FF,DDRB
movb
#$3F,DDRP
movb
#$1F,PTP
; enable display #5 to light
movb
#seven,PTB
; send out the segment pattern of 7
Example 4.14
Write a program to display 123,456 on the six seven-segment displays shown in Figure 4.18.
Solution: The digits 1, 2, 3, 4, 5, and 6 are displayed on display #5, #4, . . . , and #0, respectively.
The values to be output to Port B and Port P to display one digit at a time are shown in Table 4.8.
This table can be created by the following assembler directives:
display
dc.b
$06,$1F
; value to display 1 on seven-segment display #5
dc.b
$5B,$2F
; value to display 2 on seven-segment display #4
dc.b $4F,$37
dc.b $66,$3B
dc.b $6D,$3D
dc.b $7D,$3E
The algorithm for displaying 123,456 on the six seven-segment displays in Figure 4.18 is as
follows:
Step 1
Set ptr to point to the first byte of the display table.
Search WWH ::




Custom Search