4-8 DSP56012 User’s Manual MOTOROLA

Parallel Host Interface
Programming the GPIO

4.3 PROGRAMMING THE GPIO

The DSP56012 on-chip peripheral memory map is illustrated in Section 3, Memory,
Operating Modes, and Interrupts and in Appendix B, Programming Reference.
The standard MOVE instruction transfers data between Port B and a register. As a
result, MOVE takes two instructions to perform a memory-to-memory data transfer
and uses a temporary holding register. The MOVEP instruction is specifically
designed for I/O data transfer, as shown in Figure 4-5. Although the MOVEP
instruction can take twice as long to execute as a MOVE instruction, only one
MOVEP is required for a memory-to-memory data transfer, and MOVEP does not
use a temporary register. Using the MOVEP instruction allows a fast interrupt to
move data to/from a peripheral or from/to memory and execute one other
instruction or move the data to an absolute address. MOVEP is the only
memory-to-memory move instruction. However, one of the memory operands must
be in the top sixty-four locations of either X: or Y: memory, which are reserved for
internal and external I/O, respectively.
The bit-oriented instructions that use I/O short addressing (BCHG, BCLR, BSET,
BTST, JCLR, JSCLR, JSET, and JSSET) can also address individual bits for faster I/O
processing. The DSP does not have a hardware data strobe to move data out of the
GPIO port. If a strobe is needed, use software to toggle one of the GPIO pins to
emulate a strobe signal.
Figure 4-6 on page 4-9 illustrates the process of programming Port B as GPIO.
Generally, it is not good programming practice to activate a peripheral before
programming it. Thus, even though reset initializes the Port B as fifteen GPIO inputs,
it is best to configure Port B as GPIO inputs explicitly, and then configure the data
direction and data registers. However, some situations may require programming
the data direction or the data registers first to prevent two devices from driving one
signal. The order of steps 1, 2, and 3 in Figure 4-6 is optional and can be changed as
needed.
Figure 4-5 Instructions to Write/Read Parallel Data with Port B
MOVE #$0,X:$FFEC ;Select Port B to be
;GPIO
MOVE #$7F00,X:$FFED ;Select pins PB0–PB7 to be inputs
;and pins PB8–PB14 to be outputs
MOVEP #data_out,X:$FFEE ;Put bits 8–14 of “data_out” on pins
;PB8–PB14, bits 0–7 are ignored.
MOVEP X:$FFEE,#data_in ;Put PB0–PB7 in bits 0–7 of “data_in”