© 1999 Scenix Semiconductor, Inc. All rights reserved.
- 8 -
www.scenix.com
SX18AC / SX20AC / SX28AC
speeds. Although the device has an internal write-back
section to prevent such conditions, it is still recom-
mended that the user program include a NOP instruction
as a buffer between successive read-modify-write
instructions performed on I/O pins of the same port.
Also note that reading an I/O port is actually reading the
pins, not the output data latches. That is, if the pin output
driver is enabled and driven high while the pin is held low
externally, the port pin will read low.
3.2
Port Configuration
Each port pin offers the following configuration options:
data direction
input voltage levels (TTL or CMOS)
pullup type (pullup resistor enable or disable)
Schmitt trigger input (for Port B and Port C only)
Port B offers the additional option to use the port pins for
the Multi-Input Wakeup/Interrupt function and/or the ana-
log comparator function.
Port configuration is performed by writing to a set of con-
trol registers associated with the port. A special-purpose
instruction is used to write these control registers:
mov !RA,W (move W to Port A control register)
mov !RB,W (move W to Port B control register)
mov !RC,W (move W to Port C control register)
Each one of these instructions writes a port control regis-
ter for Port A, Port B, or Port C. There are multiple control
registers for each port. To specify which one you want to
access, you use another register called the MODE regis-
ter.
3.2.1 MODE Register
The MODE register controls access to the port configura-
tion registers. Because the MODE register is not mem-
ory-mapped, it is accessed by the following special-
purpose instructions:
mov M, #lit (move literal to MODE register)
mov M,W (move W to MODE register)
mov W,M (move MODE register to W)
The value contained in the MODE register determines
which port control register is accessed by the mov !rx,W
instruction as indicated in Table 3-3. MODE register val-
ues not listed in the table are reserved for future expan-
sion and should not be used. Therefore, the MODE
register should always contain a value from 08h to 0Fh.
Upon reset, the MODE register is initialized to 0Fh, which
enables access to the port direction registers.
After a value is written to the MODE register, that setting
remains in effect until it is changed by writing to the
MODE register again. For example, you can write the
value 0Eh to the MODE register just once, and then write
to each of the three pullup configuration registers using
the three mov !rx,W instructions.
The following code example shows how to program the
pullup control registers.
First the MODE register is loaded with 0Eh to select
access to the pullup control registers (PLP_A, PLP_B,
and PLP_C). Then the MOV !rx,W instructions are used
to specify which port pins are to be connected to the
internal pullup resistors. Setting a bit to 1 disconnects the
corresponding pullup resistor, and clearing a bit to 0 con-
nects the corresponding pullup resistor.
3.2.2 Port Configuration Registers
The port configuration registers that you control with the
MOV !rx,W instruction operate as described below.
RA, RB, and RC Data Direction Registers (MODE=0Fh)
Each register bit sets the data direction for one port pin.
Set the bit to 1 to make the pin operate as a high-imped-
ance input. Clear the bit to 0 to make the pin operate as
an output.
PLP_A, PLP_B, and PLP_C: Pullup Enable Registers
(MODE=0Eh)
Each register bit determines whether an internal pullup
resistor is connected to the pin. Set the bit to 1 to discon-
nect the pullup resistor or clear the bit to 0 to connect the
pullup resistor.
Table 3-3. MODE Register and Port
Control Register Access
MODE Reg. mov !RA,W
mov !RB,W
mov !RC,W
08h
not used
CMP_B
not used
09h
not used
WKPND_B
not used
0Ah
not used
WKED_B
not used
0Bh
not used
WKEN_B
not used
0Ch
not used
ST_B
ST_C
0Dh
LVL_A
LVL_B
LVL_C
0Eh
PLP_A
PLP_B
PLP_C
0Fh
RA Direction RB Direction RC Direction
mov
M,#$0E
;MODE=0Eh to access port pullup
;registers
mov
W,#$03
;W = 0000 0011
mov
!RA,W
;disable pullups for A0 and A1
mov
W,#$FF
;W = 1111 1111
mov
!RB,W
;disable all pullups for B0-B7
mov
W,#$00
;W = 0000 0000
mov
!RC,W
;enable all pullups for C0-C7