Programming Considerations
Within the application program, one of the first things to consider is port initialization. After a reset,
both of the I/O port registers, PA and PC, will be set high. It is important to note that if configuration
options select NMOS types, when set high the output NMOS transistor will be placed into a high im-
pedance condition, allowing the pin to be used also as an input. The generation of a high level on
the NMOS outputs therefore is reliant upon externally connected circuitry and whether pull-high
options have been selected. If configuration options select CMOS output types, these cannot be
placed into a high impedance condition and therefore cannot be used as inputs.
When using the pin as an output, its logic level can be setup by loading byte wide data into the ap-
propriate port register Port A or Port C or by programming individual bits in these registers, using
[m].i² and
[m].i² instructions. Note that when using these bit control instructions, a
read-modify-write operation takes place. The microcontroller must first read in the data on the en-
tire port, modify it to the required new bit values and then rewrite this data back to the output ports.
However, in the case of NMOS type pins, there are some special considerations that must be
noted. In the case of an NMOS pin that is set high by the microcontroller, i.e. placed into a high im-
pedance condition, but driven low by externally connected circuitry, this pin would be read as be-
ing in a low condition during the read phase of the
[m].i² and
[m].i² instructions. When
the ensuing write phase occurs, this pin, having been read as being in a low condition during the
read phase, would then be consequently erroneously set low. For this reason great care must be
taken when using these bit control instructions with NMOS output types.
T 1
S y s te m
C lo c k
T 2
T 3
T 4
T 1
T 2
T 3
T 4
P o rt D a ta
W r ite to p o r t
R e a d fro m
p o rt
Port A has the additional capability of providing wake-up functions. When the chip is in the HALT
state, various methods are available to wake the device up. One of these is a high to low transition
of any of the Port A pins. Single or multiple pins on Port A can be setup to have this function.
Home Index Bookmark Pages Text
Previous Next
Pages: Home Index