Hardware Reference
In-Depth Information
V CC
R 1
Port
pin
R 2
Port
pin
R 3
74HC04
Port
pin
(a) Positive direct drive
(b) Inverse direct drive
(c) Buffered drive
Figure 4.15 An LED connected to a CMOS inverter through a current-limiting resistor
Example 4.12
Use the HCS12 Port B to drive eight LEDs. Light each of them for half a second in turn and
repeat, assuming that the HCS12 has a 24-MHz E-clock. When the Port J pin 1 is low, the LEDs
are enabled to light. This circuit is used in the Dragon12 demo board.
Solution: The circuit for driving eight LEDs using Port B is shown in Figure 4.16.
To turn on the LED driven by pins PB7,PB0 one at a time, we output the values $80, $40, . . . ,
and $01 to Port B in turn. The procedure to achieve the desired LED display pattern is as follows:
Step 1
Place the values $80, $40, . . . , and $01 in a table. Use the index register X to point to the
start of this table. Pull the PJ1 pin low to enable LEDs to light.
Step 2
Output the value pointed to by X to Port B. Increment the pointer X.
Step 3
Wait for half a second.
HCS12
1.5 k
Ω
PB7
PB6
PB5
PB4
PB3
PB2
PB1
PB0
PJ1
Figure 4.16 Circuit connection for Example 4.12
 
Search WWH ::




Custom Search