Hardware Reference
In-Depth Information
Step 4
If X points to the end of the table, reset X to point to the start of the table.
Step 5
Go to step 2.
The assembly program that implements this algorithm is as follows:
#include “C:\miniide\hcs12.inc”
org
$1000
lpcnt
ds.b
1
org
$1500
start
movb
#$FF,DDRB
; configure port B for output
bset
DDRJ,$02
; configure PJ1 pin for output
bclr
PTJ,$02
; enable LEDs to light
forever
movb
#16,lpcnt
; initialize LED pattern count
ldx
#led_tab
; Use X as the pointer to LED pattern table
led_lp
movb
1,x 1 ,PORTB
; turn on one LED
ldy
#5
; wait for half a second
jsr
delayby100ms
; ''
dec
lpcnt
; reach the end of the table yet?
bne
led_lp
bra
forever
; start from beginning
led_tab
dc.b
$80,$40,$20,$10,$08,$04,$02,$01
dc.b
$01,$02,$04,$08,$10,$20,$40,$80
#include
“C:\miniide\delay.asm”
;
org
$FFFE
; uncomment this line for CodeWarrior
;
dc.w
start
; uncomment this line for CodeWarrior
end
4.11.2 Interfacing with Seven-Segment Displays
Seven-segment displays are often used when the embedded product needs to display only a few
digits. Seven-segment displays are mainly used to display decimal digits and a small subset of letters.
Although an HCS12 device has enough current to drive a seven-segment display, it is not advis-
able to do so when an HCS12-based embedded product needs to drive many other I/O devices. In Fig-
ure 4.17, Port B drives a common-cathode seven-segment display through the buffer chip 74HC244.
The V OH (output high voltage) value of the 74HC244 is about 5 V. Adding a 470-
resistor will set
the display segment current to about 6.4 mA, which should be sufficient to light an LED segment.
The light patterns corresponding to 10 BCD digits are shown in Table 4.7. Depending on how seg-
ments a - g are connected to the I/O pins there are two different values for displaying the same deci-
mal digit. In the Dragon12 demo board, segments a - g are connected to from the pin PB0 to pin PB6.
When an application needs to display multiple BCD digits, the time-multiplexing technique
is often used. An example of the circuit that displays six BCD digits is shown in Figure 4.18. In
Figure 4.18, the common cathode of a seven-segment display is connected to the Y output of the
hex buffer chip 74HC367. The output low voltage (V OL ) of a 74HC367 output pin (Y i , i 5 0, . . . , 5)
is about 0.33 V when the output current (the current actually flowing into the pin) is larger than a
few mA. When a port B pin output voltage is high, an LED segment current will be about 3.33 mA
[
Ω
(5 2 2 2 0.33)/800]. Total current that flows into the Y i pin is about 23.3 mA (5 7 × 3.33) and is
within the rated value of the DC output current.
 
Search WWH ::




Custom Search