English
Language : 

PIC18F66K22-I Datasheet, PDF (185/550 Pages) Microchip Technology – PIC18F87K22 Family Data Sheet
PIC18F87K22 FAMILY
12.9 PORTH, LATH and
TRISH Registers
Note: PORTH is available only on the 80-pin
devices.
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
CLRF PORTH
CLRF LATH
BANKSEL ANCON2
MOVLW 0Fh
MOVWF ANCON2
MOVLW 0Fh
MOVWF ANCON1
BANKSEL TRISH
MOVLW 0CFh
MOVWF TRISH
; Initialize PORTH by
; clearing output
; data latches
; Alternate method
; to clear output
; data latches
; Select bank with ANCON2 register
; Configure PORTH as
; digital I/O
; Configure PORTH as
; digital I/O
; Select bank with TRISH register
; Value used to
; initialize data
; direction
; 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
AN23
0
O
DIG LATH<0> data output.
1
I
ST PORTH<0> data input.
1
I
ANA A/D Input Channel 23.
Default input configuration on POR; does not affect digital input.
RH1/AN22/A17
RH2/AN21/A18
RH3/AN20/A19
A16
RH1
AN22
A17
RH2
AN21
A18
RH3
AN20
x
O
DIG External memory interface, Address Line 16; takes priority over port
data.
0
O
DIG LATH<1> data output.
1
I
ST PORTH<1> data input.
1
I
ANA A/D Input Channel 22.
Default input configuration on POR; does not affect digital input.
x
O
DIG External memory interface, Address Line 17; takes priority over port
data.
0
O
DIG LATH<2> data output.
1
I
ST PORTH<2> data input.
1
I
ANA A/D Input Channel 21.
Default input configuration on POR; does not affect digital input.
x
O
DIG External memory interface, Address Line 18; takes priority over port
data.
0
O
DIG LATH<3> data output.
1
I
ST PORTH<3> data input.
1
I
ANA A/D Input Channel 20.
Default input configuration on POR; does not affect digital input.
Legend:
A19
x
O
DIG External memory interface, Address Line 19; takes priority over port
data.
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).
 2009-2011 Microchip Technology Inc.
DS39960D-page 185