Hardware Reference
In-Depth Information
pula
; 3 E cycles
psha
; 2 E cycles
pula
; 3 E cycles
psha
; 2 E cycles
pula
; 3 E cycles
nop
; 1 E cycle
nop
; 1 E cycle
dbne
x,iloop3
; 3 E cycles
dbne
y,eloop3
; 3 E cycles
pulx
rts
The subroutines that can generate a delay that is a multiple of an other value (for example,
1 ms or 10 ms) can be created in the same manner. The delay.asm file in the complementary CD
provides the following delay subroutines that the user can call to generate delays that are a
multiple of 50
s, 1 ms, 10 ms, and 100 ms with the multiple also passed in Y:
delayby50μs
delayby1ms
delayby10ms
delayby100ms
μ
4.10 Introduction to Parallel I/O Port and Simple I/O Devices
So far we have considered how to write general-purpose assembly programs which do not
involve any microcontroller peripheral functions. Dealing with peripheral functions and I/O
devices will add great fun to the learning of assembly language programming. The purpose of
this section is to introduce the parallel I/O port, simple I/O devices, and their applications.
An HCS12 device may have from 48 to 144 signal pins arranged in 3 to 12 I/O ports. Most
signal pins serve multiple functions. When a pin is not used by any peripheral function, it can
be used for general-purpose input/output such as driving an LED or a switch. An I/O port con-
sists of a set of I/O pins and the registers required to control its operations. The I/O pins associ-
ated with an I/O port may be configured for input or output and can be used to output values to
LEDs or LCDs or input values from DIP switches or keypad directly.
The pin assignment of the HCS12 D subfamily is shown in Figure 4.14. Most I/O ports have
eight pins although a few do not. A summary of the HCS12 I/O ports is listed in Table 4.5.
4.10.1 Addressing the I/O Port Register
To perform input and output, the CPU sends data to or from a register instead of dealing
with I/O pins. Each register is assigned an address. The user accesses a register by specifying the
address assigned to it. For example, the Port A data register is assigned to address 0. The follow-
ing instruction will output the value $35 to Port A:
movb #$35,0 ; address 0 is Port A data register
However, it is quite difficult to read the program that performs I/O operations that refers
to the address of a port data register. Instead, the user can use an equ directive to make the
instruction more readable:
PTA
equ
0
movb
#$35,PTA
 
Search WWH ::




Custom Search