Microchip Technology DM183037 Data Sheet

Page of 696
 2012 Microchip Technology Inc.
DS30575A-page 211
PIC18F97J94 FAMILY
11.7
PORTF, LATF and TRISF Registers
PORTF is a 6-bit wide, bidirectional port. The
corresponding Data Direction and Output Latch registers
are TRISF and LATF. All pins on PORTF are
implemented with Schmitt Trigger input buffers. Each pin
is individually configurable as an input or output.
Pins, RF2 through RF6, may be used as comparator
inputs or outputs by setting the appropriate bits in the
CMCON register. To use RF<7:2> as digital inputs, it is
also necessary to turn off the comparators. 
EXAMPLE 11-6:
INITIALIZING PORTF 
Note 1: On device Resets, pins, RF<7:2>, are
configured as analog inputs and are read
as ‘0’.
2: To configure PORTF as a digital I/O, turn
off the comparators and clear ANCON1
and ANCON2 to digital.
CLRF
PORTF
; Initialize PORTF by
; clearing output
; data latches
CLRF
LATF
; Alternate method
; to clear output
; data latches
BANKSEL
ANCON1
; Select bank with ANCON1 register
MOVLW
1Fh
; Make AN6, AN7 and AN5 digital
MOVWF
ANCON1
;
MOVLW
0Fh
; Make AN8, AN9, AN10 and AN11
  digital
MOVWF
ANCON
; Set PORTF as digital I/O
BANKSEL
TRISF
; Select bank with TRISF register
MOVLW
0CEh
; Value used to
; initialize data
; direction
MOVWF
TRISF
; Set RF3:RF2 as inputs
; RF5:RF4 as outputs
; RF7:RF6 as inputs
TABLE 11-6:
PORTF FUNCTIONS
Pin Name
Function
TRIS 
Setting
I/O
I/O 
Type
Description
RF0
PORTF<0> is not implemented.
RF1
PORTF<1> is not implemented.
RF2/RP36/C2INB/
CTMUI/SEG20/
AN7
RF2
0
O
DIG
LATF<2> data output.
1
I
ST
PORTF<2> data input.
RP36
x
x
DIG
Reconfigurable Pin 36 for PPS-Lite; TRIS must be set to match 
input/output of module.
C2INB
1
I
ANA
Comparator 2 Input B.
CTMUI
1
I
ANA
CTMU comparator input.
SEG20
0
O
ANA
LCD Segment 20 output; disables all other pin functions.
AN7
1
I
ANA
A/D Input Channel 7. Default input configuration on POR; does not 
affect digital output.
RF3/RP41/D-
RF3
0
O
DIG
LATF<3> data output.
1
I
ST
PORTF<3> data input.
RP41
x
x
DIG
Reconfigurable Pin 41 for PPS-Lite; TRIS must be set to match 
input/output of module.
D-
x
I
XCVR
USB bus minus line output.
x
O
XCVR
USB bus minus line input.
RF4/RP45/D+
RF4
0
O
DIG
LATF<4> data output.
1
I
ST
PORTF<4> data input.
RP45
x
x
DIG
Reconfigurable Pin 45 for PPS-Lite.
D+
x
I
XCVR
USB bus plus line input.
x
O
XCVR
USB bus plus line output.
Legend:
O = Output, I = Input, ANA = Analog Signal, DIG = Digital Output, ST = Schmitt Trigger Buffer Input, 
XCVR = USB Transceiver, x = Don’t care (TRIS bit does not affect port direction or is overridden for this option).