English
Language : 

PIC18F44J50-I Datasheet, PDF (146/562 Pages) Microchip Technology – 28/44-Pin, Low-Power, High-Performance USB Microcontrollers
PIC18F46J50 FAMILY
10.5 PORTD, TRISD and LATD
Registers
Note: PORTD is available only on 44-pin devices.
PORTD is an 8-bit wide, bidirectional port. The corre-
sponding Data Direction register is TRISD. Setting a
TRISD bit (= 1) will make the corresponding PORTD
pin an input (i.e., put the corresponding output driver in
a High-Impedance mode). Clearing a TRISD bit (= 0)
will make the corresponding PORTD pin an output (i.e.,
put the contents of the output latch on the selected pin).
The Data Latch register (LATD) is also memory
mapped. Read-modify-write operations on the LATD
register read and write the latched output value for
PORTD.
All pins on PORTD are implemented with Schmitt Trigger
input buffers. Each pin is individually configurable as an
input or an output.
Note: On a POR, these pins are configured as
digital inputs.
EXAMPLE 10-5:
CLRF LATD
MOVLW 0x7F
MOVWF TRISD
INITIALIZING PORTD
;Initialize output data
;levels for output pins
;Example value used to
;initialize data direction
;RD0-RD6 as inputs
;RD7 as output
Each of the PORTD pins has a weak internal pull-up. A
single control bit can turn on all the pull-ups. This is per-
formed by setting bit, RDPU (PORTE<7>). The weak
pull-up is automatically turned off when the port pin is
configured as an output. The pull-ups are disabled on a
POR. The integrated weak pull-ups consist of a semi-
conductor structure similar to, but somewhat different,
from a discrete resistor. On an unloaded I/O pin, the
weak pull-ups are intended to provide logic high indica-
tion, but will not necessarily pull the pin all the way to
VDD levels.
Note that the pull-ups can be used for any set of
features, similar to the pull-ups found on PORTB.
TABLE 10-9: PORTD I/O SUMMARY
Pin
Function
TRIS
Setting
I/O
I/O
Type
Description
RD0/PMD0/
SCL2
RD0
1
I
ST PORTD<0> data input.
0
O DIG LATD<0> data output.
PMD0
1
I ST/TTL Parallel Master Port data in.
SCL2
0
O DIG Parallel Master Port data out.
1
I
I2C/ I2C™ clock input (MSSP2 module); input type depends on
SMB module setting.
0
O I2C I2C clock output (MSSP2 module); takes priority over port data.
RD1/PMD1/
SDA2
RD1
1
I
ST PORTD<1> data input.
0
O DIG LATD<1> data output.
PMD1
1
I ST/TTL Parallel Master Port data in.
SDA2
0
O DIG Parallel Master Port data out.
1
I
I2C/ I2C data input (MSSP2 module); input type depends on
SMB module setting.
0
O I2C I2C data output (MSSP2 module); takes priority over port data.
RD2/PMD2/
RP19
RD2
1
I
ST PORTD<2> data input.
0
O DIG LATD<2> data output.
PMD2
1
I ST/TTL Parallel Master Port data in.
0
O DIG Parallel Master Port data out.
RP19
1
I
ST Remappable Peripheral Pin 19 input.
0
O DIG Remappable Peripheral Pin 19 output.
Legend: DIG = Digital level output; TTL = TTL input buffer; ST = Schmitt Trigger input buffer; I2C/SMB = I2C/SMBus
input buffer; x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).
DS39931D-page 146
 2011 Microchip Technology Inc.