Microchip Technology MCU PIC PIC18F87K22-I/PTRSL TQFP-80 MCP PIC18F87K22-I/PTRSL Hoja De Datos

Los códigos de productos
PIC18F87K22-I/PTRSL
Descargar
Página de 550
PIC18F87K22 FAMILY
DS39960D-page 176
 2009-2011 Microchip Technology Inc.
12.5
PORTD, TRISD and 
LATD Registers
PORTD is an 8-bit wide, bidirectional port. The
corresponding Data Direction and Output Latch registers
are TRISD and LATD.
All pins on PORTD are implemented with Schmitt
Trigger input buffers. Each pin is individually
configurable as an input or output.
Each of the PORTD pins has a weak internal pull-up. A
single control bit can turn off all the pull-ups. This is
performed by setting bit, RDPU (PADCFG1<7>). The
weak pull-up is automatically turned off when the port
pin is configured as an output. The pull-ups are
disabled on all device Resets.
On 80-pin devices, PORTD is multiplexed with the
system bus as part of the external memory interface.
The I/O port and other functions are only available
when the interface is disabled by setting the EBDIS bit
(MEMCON<7>). When the interface is enabled,
PORTD is the low-order byte of the multiplexed
address/data bus (AD<7:0>). The TRISD bits are also
overridden.
PORTD can also be configured as an 8-bit wide micro-
processor port (Parallel Slave Port) by setting control
bit, PSPMODE (TRISE<4>). In this mode, the input
buffers are TTL. For additional information, see
.
The PORTD also has the I
2
C and SPI functionality on
RD4, RD5 and RD6. The pins for SPI are also configu-
rable for open-drain output. Open-drain configuration is
selected by setting bit, SSP2OD (ODCON1<0>).
RD0 has a CTMU functionality. RD1 has the functional-
ity for the Timer5 clock input and Timer7 external clock
gate input.
EXAMPLE 12-4:
INITIALIZING PORTD      
Note:
These pins are configured as digital inputs
on any device Reset.
CLRF
PORTD
;
  Initialize PORTD by
 
; clearing output
 
; data latches
CLRF
LATD
; Alternate method
; to clear output
; data latches
MOVLW
 
0CFh
;
  Value used to 
; initialize data 
; direction
MOVWF
 
TRISD
;
  Set RD<3:0> as inputs
;
  RD<5:4> as outputs
;
  RD<7:6> as inputs
TABLE 12-7:
PORTD FUNCTIONS
Pin Name
Function
TRIS 
Setting
I/O
I/O 
Type
Description
RD0/PSP0/
AD0/CTPLS
RD0
0
O
DIG
LATD<0> data output.
1
I
ST
PORTD<0> data input.
PSP0
)
 
x
I/O
TTL
Parallel Slave Port data.
AD0
 
x
I/O
TTL
External Memory Address/Data 0.
CTPLS
x
O
DIG
CTMU pulse generator output.
RD1/PSP1/
AD1/T5CKI/
T7G
RD1
0
O
DIG
LATD<1> data output.
1
I
ST
PORTD<1> data input.
PSP1
)
 
x
I/O
TTL
Parallel Slave Port data.
AD1
 
x
I/O
TTL
External Memory Address/Data 1.
T5CKI
x
I
ST
Timer5 clock input.
T7G
x
I
ST
Timer7 external clock gate input.
RD2/PSP2/AD2
RD2
0
O
DIG
LATD<2> data output.
1
I
ST
PORTD<2> data input.
PSP2
)
 
x
I/O
TTL
Parallel Slave Port data.
AD2
 
x
I/O
TTL
External Memory Address/Data 2.
Legend:
O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Trigger Buffer Input, 
I
2
C = I
2
C™/SMBus Buffer Input, x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
Note
1:
The Parallel Slave Port (PSP) is available only in Microcontroller mode.
2:
This feature is available only on PIC18F8XK22 devices.