Hardware Reference
In-Depth Information
The HCS12 I/O ports can drive many different types of I/O devices directly. It is important
to consider the electrical and timing compatibility issues when driving I/O devices. These two
issues will be discussed in more detail in Chapter 7. The function of each signal pin will also be
discussed in more detail in Chapter 7.
The LED is a simple output device. It is often used to indicate whether power is turned on,
whether the device is functioning properly, and so on. Today, LEDs also replace incandescent
light bulbs because LEDs are much more energy efficient.
Seven-segment displays are mainly used to display small amounts of information using
decimal digits and a smaller set of characters. Due to the availability of a wide range of sizes,
seven-segment displays have become one of the most versatile display devices.
DIP switches are often used to provide information to the startup program of many embed-
ded systems. After being powered up, the MCU reads the DIP switch's setting and configures
the embedded system accordingly. Users can change the setting of DIP switches to change the
system configuration.
4.14 Exercises
E4.1 Assuming that we have the following instruction sequence to be executed by the HCS12,
what will be the contents of the topmost 4 bytes of the stack after the execution of these
instructions?
lds #$1500
ldaa #$56
staa 1, 2 SP
ldab #22
staa 1, 2 SP
ldy #0
sty 2, 2 SP
E4.2 Write instructions to perform the following operation:
1) Push the value $2301 (word value) onto the stack
2) Push the value $34 (byte value) onto the stack
3) Pop the top word of the stack and save it at memory location $1000,$1001.
4) Push the 16-bit value stored at $1000,$1001 into the stack
E4.3 Revise the subroutine in Example 4.2 so that it can convert a 16-bit signed integer to a
BCD string.
E4.4 Write a subroutine to fi nd the greatest common divisor of two 16-bit unsigned integers.
These two 16-bit numbers are passed in the stack. The subroutine returns the gcd in double
accumulator D.
E4.5 Write a subroutine to convert all the lowercase letters in a string to uppercase. The pointer
to the string is passed to this subroutine in X.
E4.6 The label array_x is the starting address of an array of 100 8-bit elements. Trace the fol-
lowing code sequence and describe what the subroutine sub_x does:
ldx
#array_x
ldaa
#100
jsr
sub_x
 
Search WWH ::




Custom Search