Datasheet
1998-2013 Microchip Technology Inc. DS30289C-page 75
PIC17C7XX
Example 10-2 shows an instruction sequence to initial-
ize PORTB. The Bank Select Register (BSR) must be
selected to Bank 0 for the port to be initialized. The fol-
lowing example uses the MOVLB instruction to load the
BSR register for bank selection.
EXAMPLE 10-2: INITIALIZING PORTB
FIGURE 10-6: BLOCK DIAGRAM OF RB3:RB2 PORT PINS
MOVLB 0 ; Select Bank 0
CLRF PORTB, F ; Init PORTB by clearing
; output data latches
MOVLW 0xCF ; Value used to initialize
; data direction
MOVWF DDRB ; Set RB<3:0> as inputs
; RB<5:4> as outputs
; RB<7:6> as inputs
Note: I/O pins have protection diodes to VDD and VSS.
Data Bus
Q
D
CK
Q
D
CK
R
Weak
Pull-up
Port
Input Latch
Port
Data
OE
Peripheral_enable
Peripheral_output
WR_PORTB (Q4)
WR_DDRB (Q4)
RD_PORTB (Q2)
RD_DDRB (Q2)
RBIF
RBPU
Match Signal
from other
port pins
(PORTA<7>)
Peripheral Data In