English
Language : 

PIC18F44J50-I Datasheet, PDF (136/562 Pages) Microchip Technology – 28/44-Pin, Low-Power, High-Performance USB Microcontrollers
PIC18F46J50 FAMILY
10.2 PORTA, TRISA and LATA Registers
PORTA is a 7-bit wide, bidirectional port. It may also
function as a 5-bit or 6-bit port, depending on the oscil-
lator mode selected. Setting a TRISA bit (= 1) will make
the corresponding PORTA pin an input (i.e., put the
corresponding output driver in a High-Impedance
mode). Clearing a TRISA bit (= 0) will make the
corresponding PORTA pin an output (i.e., put the
contents of the output latch on the selected pin).
Reading the PORTA register reads the status of the
pins, whereas writing to it, will write to the port latch.
The Data Latch (LATA) register is also memory mapped.
Read-modify-write operations on the LATA register read
and write the latched output value for PORTA.
Most PORTA pins are multiplexed with analog (ANx)
functionality. In order to use the analog capable pins as
digital inputs, the corresponding PCFG bits in the
ANCON0 register must be set.
Pins, RA0 through RA3, may also be used as compara-
tor inputs by setting the appropriate bits in the CMxCON
registers and configuring the pins as analog inputs.
Note:
On a Power-on Reset (POR), RA5 and
RA<3:0> are configured as analog inputs
and read as ‘0’.
All PORTA pins have full CMOS output drivers.
The TRISA register controls the direction of the PORTA
pins, even when they are being used as analog inputs.
EXAMPLE 10-2: INITIALIZING PORTA
CLRF LATA
MOVLW
MOVFF
MOVLW
0x1F
WREG,ANCON0
0xCF
MOVWF TRISA
;Clearing the PORTA latches
;will cause the pins to drive
;low if configured as outputs
;Configure AN0-AN4 pins
;for digital input mode
;Example value used to
;initialize data direction
;Set RA<3:0> as inputs
;RA4 is unimplemented
;RA5 as output
;RA6 and RA7 as inputs
;(unless overridden by osc settings)
DS39931D-page 136
 2011 Microchip Technology Inc.