Datasheet

2013 Microchip Technology Inc. DS22331A-page 109
MCP19111
19.0 I/O PORTS
In general, when a peripheral is enabled, that pin may
not be used as a general purpose I/O pin.
Each port has two registers for its operation. These
registers are:
TRISx registers (data direction register)
PORTGPx registers (reads the levels on the pins
of the device)
Some ports may have one or more of the following
additional registers. These registers are:
ANSELx (analog select)
WPUx (weak pull-up)
Ports with analog functions also have an ANSELx
register, which can disable the digital input and save
power. A simplified model of a generic I/O port, without
the interfaces to other peripherals, is shown in
Figure 19-1.
FIGURE 19-1: GENERIC I/O PORTGPX
OPERATION
EXAMPLE 19-1: INITIALIZING PORTA
QD
CK
Write LATx
Data Register
I/O pin
Read PORTx
Write PORTx
TRISx
Read LATx
Data Bus
To peripherals
ANSELx
V
DD
V
SS
; This code example illustrates
; initializing the PORTGPA register. The
; other ports are initialized in the same
; manner.
BANKSEL PORTGPA;
CLRF PORTGPA;Init PORTA
BANKSEL ANSELA;
CLRF ANSELA;digital I/O
BANKSEL TRISGPA;
MOVLW B'00011111';Set GPA<4:0> as
;inputs
MOVWF TRISGPA;and set GPA<7:6> as
;outputs