Datasheet

PIC18F97J60 FAMILY
DS39762F-page 160 2011 Microchip Technology Inc.
11.7 PORTF, LATF and TRISF Registers
PORTF is implemented as a bidirectional port in two
different ways:
64-pin and 80-pin devices: 7 bits wide (RF<7:1>)
100-pin devices: 8 bits wide (RF<7:0>)
The corresponding Data Direction register is TRISF.
Setting a TRISF bit (= 1) will make the corresponding
PORTF pin an input (i.e., put the corresponding output
driver in a High-Impedance mode). Clearing a TRISF
bit (= 0) will make the corresponding PORTF pin an
output (i.e., put the contents of the output latch on the
selected pin). Only Pin 7 of PORTF has no analog
input; it is the only pin that can tolerate voltages up to
5.5V.
The Output Latch register (LATF) is also memory
mapped. Read-modify-write operations on the LATF
register read and write the latched output value for
PORTF.
All pins on PORTF are implemented with Schmitt
Trigger input buffers. Each pin is individually
configurable as an input or output.
PORTF is multiplexed with several analog peripheral
functions, including the A/D Converter and comparator
inputs, as well as the comparator outputs. Pins, RF1
through RF6, may be used as comparator inputs or
outputs by setting the appropriate bits in the CMCON
register. To use RF<6:1> as digital inputs, it is also
necessary to turn off the comparators.
EXAMPLE 11-6: INITIALIZING PORTF
Note 1: On device Resets, pins, RF<6:1>, are
configured as analog inputs and are read
as ‘0’.
2: To configure PORTF as digital I/O, turn
off the comparators and set the ADCON1
value.
CLRF PORTF ; Initialize PORTF by
; clearing output
; data latches
CLRF LATF ; Alternate method
; to clear output
; data latches
MOVLW 07h ;
MOVWF CMCON ; Turn off comparators
MOVLW 0Fh ;
MOVWF ADCON1 ; Set PORTF as digital I/O
MOVLW 0CEh ; Value used to
; initialize data
; direction
MOVWF TRISF ; Set RF3:RF1 as inputs
; RF5:RF4 as outputs
; RF7:RF6 as inputs