English
Language : 

PIC17C7XX_13 Datasheet, PDF (80/306 Pages) Microchip Technology – High-Performance 8-bit CMOS EPROM Microcontrollers with 10-bit A/D
PIC17C7XX
10.4 PORTD and DDRD Registers
PORTD is an 8-bit bi-directional port. The correspond-
ing data direction register is DDRD. A '1' in DDRD con-
figures the corresponding port pin as an input. A '0' in
the DDRD register configures the corresponding port
pin as an output. Reading PORTD reads the status of
the pins, whereas writing to PORTD will write to the port
latch. PORTD is multiplexed with the system bus.
When operating as the system bus, PORTD is the high
order byte of the address/data bus (AD15:AD8). The
timing for the system bus is shown in the Electrical
Specifications section.
Note:
This port is configured as the system bus
when the device’s configuration bits are
selected to Microprocessor or Extended
Microcontroller modes. In the two other
microcontroller modes, this port is a gen-
eral purpose I/O.
Example 10-4 shows an instruction sequence to initial-
ize PORTD. The Bank Select Register (BSR) must be
selected to Bank 1 for the port to be initialized. The fol-
lowing example uses the MOVLB instruction to load the
BSR register for bank selection.
EXAMPLE 10-4: INITIALIZING PORTD
MOVLB
CLRF
MOVLW
MOVWF
1
PORTD, F
0xCF
DDRD
; Select Bank 1
; Initialize PORTD data
; latches before setting
; the data direction reg
; Value used to initialize
; data direction
; Set RD<3:0> as inputs
; RD<5:4> as outputs
; RD<7:6> as inputs
FIGURE 10-10:
BLOCK DIAGRAM OF RD7:RD0 PORT PINS (IN I/O PORT MODE)
To D_Bus  IR
INSTRUCTION READ
TTL
Input
Buffer
Data Bus
RD_PORTD
0 Port
Data
1
Q
D
CK
WR_PORTD
Q
D
CK
RS
Note: I/O pins have protection diodes to VDD and VSS.
RD_DDRD
WR_DDRD
EX_EN
DATA/ADDR_OUT
DRV_SYS
System Bus
Control
DS30289C-page 80
 1998-2013 Microchip Technology Inc.