Mikroelektronika MikroE Development Kits MIKROE-997 Data Sheet
Product codes
MIKROE-997
© 2009 Microchip Technology Inc.
DS39775C-page 155
PIC18F87J50 FAMILY
10.7
PORTF, LATF and TRISF Registers
PORTF is a 6-bit wide, bidirectional port. RF2, RF5 and
RF6 are analog inputs. These ports are configured as
analog inputs on a device Reset.
All pins on PORTF are implemented with Schmitt Trig-
ger input buffers. Each pin is individually configurable
as an input or output.
Pins, RF3 and RF4, are multiplexed with the USB mod-
ule. Depending on the configuration of the module, they
can serve as the differential data lines for the on-chip
USB transceiver. Both RF3 and RF4 have Schmitt
Trigger input buffers. As digital ports, they can only
function as digital inputs; the on-chip USB transceiver
must be disabled (UTRDIS (UCFG<3>) bit = 1) to use
the pin as digital inputs. When configured for USB oper-
ation, the data direction is determined automatically by
the configuration and status of the USB module at any
given time.
RF6 are analog inputs. These ports are configured as
analog inputs on a device Reset.
All pins on PORTF are implemented with Schmitt Trig-
ger input buffers. Each pin is individually configurable
as an input or output.
Pins, RF3 and RF4, are multiplexed with the USB mod-
ule. Depending on the configuration of the module, they
can serve as the differential data lines for the on-chip
USB transceiver. Both RF3 and RF4 have Schmitt
Trigger input buffers. As digital ports, they can only
function as digital inputs; the on-chip USB transceiver
must be disabled (UTRDIS (UCFG<3>) bit = 1) to use
the pin as digital inputs. When configured for USB oper-
ation, the data direction is determined automatically by
the configuration and status of the USB module at any
given time.
When Configuration bit, PMPMX = 0, PORTF is multi-
plexed with Parallel Master data port. This multiplexing
is available only in 80 pin devices.
plexed with Parallel Master data port. This multiplexing
is available only in 80 pin devices.
EXAMPLE 10-6:
INITIALIZING PORTF
Note 1: On device Resets, pins RF2, RF5 and
RF6 are configured as analog inputs and
are read as ‘0’.
are read as ‘0’.
2: To configure PORTF as digital I/O, set the
corresponding bits in ANCON0 and
ANCON1.
ANCON1.
CLRF
PORTF
; Initialize PORTF by
; clearing output
; data latches
; clearing output
; data latches
CLRF
LATF
; Alternate method to
; clear output latches
BSF
WDTCON,ADSHR ; Enable write/read to
; the shared SFR
MOVLW
80h
; make RF2 digital
MOVWF
ANCON0
;
MOVLW
0Ch
; make RF<6:5> digital
MOVWF
ANCON1
;
BCF
WDTCON,ADSHR ; Disable write/read to
; the shared SFR
MOVLW
C0h ;
MOVWF
TRISF
; Set RF5:RF2 as outputs,
; RF<7:6> as inputs
; RF<7:6> as inputs