Datasheet
2009-2011 Microchip Technology Inc. DS39960D-page 185
PIC18F87K22 FAMILY
12.9 PORTH, LATH and
TRISH Registers
PORTH is an 8-bit wide, bidirectional I/O port. The
corresponding Data Direction and Output Latch registers
are TRISH and LATH.
All pins on PORTH are implemented with Schmitt
Trigger input buffers. Each pin is individually
configurable as an input or output.
EXAMPLE 12-8: INITIALIZING PORTH
Note: PORTH is available only on the 80-pin
devices.
CLRF PORTH ; Initialize PORTH by
; clearing output
; data latches
CLRF LATH ; Alternate method
; to clear output
; data latches
BANKSEL ANCON2 ; Select bank with ANCON2 register
MOVLW 0Fh ; Configure PORTH as
MOVWF ANCON2 ; digital I/O
MOVLW 0Fh ; Configure PORTH as
MOVWF ANCON1 ; digital I/O
BANKSEL TRISH ; Select bank with TRISH register
MOVLW 0CFh ; Value used to
; initialize data
; direction
MOVWF TRISH ; Set RH3:RH0 as inputs
; RH5:RH4 as outputs
; RH7:RH6 as inputs
TABLE 12-15: PORTH FUNCTIONS
Pin Name Function
TRIS
Setting
I/O
I/O
Type
Description
RH0/AN23/A16 RH0 0 O DIG LATH<0> data output.
1 I ST PORTH<0> data input.
AN23 1 I ANA A/D Input Channel 23.
Default input configuration on POR; does not affect digital input.
A16 x O DIG External memory interface, Address Line 16; takes priority over port
data.
RH1/AN22/A17 RH1 0 O DIG LATH<1> data output.
1 I ST PORTH<1> data input.
AN22 1 I ANA A/D Input Channel 22.
Default input configuration on POR; does not affect digital input.
A17 x O DIG External memory interface, Address Line 17; takes priority over port
data.
RH2/AN21/A18 RH2 0 O DIG LATH<2> data output.
1 I ST PORTH<2> data input.
AN21 1 I ANA A/D Input Channel 21.
Default input configuration on POR; does not affect digital input.
A18 x O DIG External memory interface, Address Line 18; takes priority over port
data.
RH3/AN20/A19 RH3 0 O DIG LATH<3> data output.
1 I ST PORTH<3> data input.
AN20 1 I ANA A/D Input Channel 20.
Default input configuration on POR; does not affect digital input.
A19 x O DIG External memory interface, Address Line 19; takes priority over port
data.
Legend: O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Trigger Buffer Input,
x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).