English
Language : 

AT89LP2052_06 Datasheet, PDF (20/90 Pages) ATMEL Corporation – 8-bit Microcontroller with 2/4-Kbyte Flash
14.6
Port Read-Modify-Write
A read from a port will read either the state of the pins or the state of the port register depending
on which instruction is used. Simple read instructions will always access the port pins directly.
Read-modify-write instructions, which read a value, possibly modify it, and then write it back, will
always access the port register. This includes bit write instructions such as CLR or SETB as they
actually read the entire port, modify a single bit, then write the data back to the entire port. See
Table 14-2 for a complete list of Read-Modify-Write instruction which may access the ports.
Table 14-2. Port Read-Modify-Write Instructions
Mnemonic
Instruction
ANL
Logical AND
ORL
Logical OR
XRL
Logical EX-OR
JBC
Jump if bit set and clear bit
CPL
Complement bit
INC
Increment
DEC
Decrement
DJNZ
Decrement and jump if not zero
MOV PX.Y, C
Move carry to bit Y of Port X
CLR PX.Y
Clear bit Y of Port X
SETB PX.Y
Set bit Y of Port X
Example
ANL P1, A
ORL P1, A
XRL P1, A
JBC P3.0, LABEL
CPL P3.1
INC P1
DEC P3
DJNZ P3, LABEL
MOV P1.0, C
CLR P1.1
SETB P3.2
14.7
Port Alternate Functions
Most general-purpose digital I/O pins of the AT89LP2052/LP4052 share functionality with the
various I/Os needed for the peripheral units. Table 14-4 lists the alternate functions of the port
pins. Alternate functions are connected to the pins in a logic AND fashion. In order to enable the
alternate function on a port pin, that pin must have a “1” in its corresponding port register bit, oth-
erwise, the input/output will always be “0”. Furthermore, each pin must be configured
for the correct input/output mode as required by its peripheral before it may be used as such.
Table 14-3 shows how to configure a generic pin for use with an alternate function.
Table 14-3.
PxM0.y
0
0
1
1
Alternate Function Configurations for Pin y of Port x
PxM1.y
Px.y
I/O Mode
0
1
Bidirectional (internal pull-up)
1
1
Output
0
X
Input
1
1
Bidirectional (external pull-up)
20 AT89LP2052/LP4052
3547F–MICRO–6/06