PIC18F25J50 MICROCHIP [Microchip Technology], PIC18F25J50 Datasheet - Page 131

no-image

PIC18F25J50

Manufacturer Part Number
PIC18F25J50
Description
28/44-Pin, Low-Power, High-Performance USB Microcontrollers with nanoWatt XLP Technology
Manufacturer
MICROCHIP [Microchip Technology]
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
PIC18F25J50-I/SO
Manufacturer:
MICROCHIP
Quantity:
1 001
Part Number:
PIC18F25J50-I/SP
Manufacturer:
MICROCHIP
Quantity:
1 001
Part Number:
PIC18F25J50-I/SS
Manufacturer:
MICROCHIP
Quantity:
1 001
Part Number:
PIC18F25J50T-I/SO
Manufacturer:
MICROCHIP
Quantity:
1 001
Part Number:
PIC18F25J50T-I/SS
Manufacturer:
MICROCHIP
Quantity:
1 001
10.0
Depending on the device selected and features
enabled, there are up to five ports available. Some pins
of the I/O ports are multiplexed with an alternate
function from the peripheral features on the device. In
general, when a peripheral is enabled, that pin may not
be used as a general purpose I/O pin.
Each port has three registers for its operation. These
registers are:
• TRIS register (Data Direction register)
• PORT register (reads the levels on the pins of the
• LAT register (Data Latch)
Pins that are multiplexed with analog functionality (ANx
pins) also have ANCON register bits associated with
them.
The TRISx registers control which pins should be con-
figured as digital outputs (output buffer enabled) and
which pins should be left high-impedance. Writing ‘0’ to
a TRIS bit configures the specified pin as a digital out-
put. Writing a ‘1’ to a TRIS bit disables the output driver,
so the pin can be used as a digital or analog input. This
can be easily remembered by observing that ‘0’ is sim-
ilar to the letter, O (as in Output), and that ‘1’ is similar
to the letter, I (as in Input).
The PORTx registers can be used to read the logic level
externally presented on pins that have been configured
as digital inputs. If a pin is configured as a digital input,
the corresponding port bit will be read as ‘1’ if the exter-
nally applied voltage is greater than the V
pin. If the externally applied voltage is below V
the PORTx bit will read as ‘0’. If the I/O pin is multiplexed
with analog functionality (an ANx pin), then the corre-
sponding PCFG bit, in the appropriate ANCONx register,
must also be set, in order to correctly read the externally
applied voltage on the pin. See the following information
regarding the ANCONx registers.
If the application firmware writes to a PORTx register,
this will cause the corresponding LATx register to be
updated. It is usually not recommended to perform
read-modify-write instructions (ex: BTG, BSF, BCF) on a
PORTx register. If the application firmware wishes to
change the output state of a pin that has been
configured as a digital output (TRIS bit = 0), it is
recommended that the firmware use the corresponding
LATx register instead.
The LATx registers hold the digital value that is output
onto a pin when the pin has been configured as a digital
output (TRIS bit = 0). Writing a ‘1’ to the LATx bit will
drive the output pin to the logic high output state.
Similarly, writing a ‘0’ to the LAT bit will drive the output
pin to a logic low output state. It is safe to perform all
types of read, write and read-modify-write instructions
on the LATx registers.
 2011 Microchip Technology Inc.
device)
I/O PORTS
IH
level for that
IL
, then
PIC18F46J50 FAMILY
The ANCONx registers are used to configure pins with
ANx analog functionality for either Digital Input or Analog
Input mode. Setting a PCFG bit in an ANCONx register
enables the digital input buffer, allowing reads from the
PORTx register to correctly reflect the externally applied
voltage on the digital input pin. If the PCFG bit is clear,
the digital input buffer is disabled, to eliminate CMOS
input buffer cross conduction currents, when a mid-V
scale analog voltage is applied to the pin. This allows
analog input voltages (between V
applied to the pin without increasing the current con-
sumption of the device. If the appropriate PCFG bit in the
ANCONx register is not set, this will cause the PORTx
register bit for that pin to read as ‘0’, regardless of the
actually applied external voltage.
At power-up, the default state of the ANCONx registers
is to configure the ANx pins for Analog mode (digital
input buffer off). Therefore, to use ANx pins as digital
inputs, the application firmware must first update the
ANCONx register(s). See
log-to-Digital Converter (A/D) Module”
details regarding the ANCONx registers.
Figure 10-1
port, without the interfaces to other peripherals.
FIGURE 10-1:
RD LAT
Data
Bus
WR LAT
or PORT
WR TRIS
RD TRIS
RD PORT
Note 1: I/O pins without 5.5V tolerance have diode
displays a simplified model of a generic I/O
protection to V
5.5V tolerance have diode protection from
Vss.
TRIS Latch
Data Latch
D
D
CK
CK
GENERIC I/O PORT
OPERATION
Q
Q
DD
Section 21.0 “10-bit Ana-
and V
Q
EN
DD
SS
DS39931D-page 131
EN
D
. I/O pins with
and V
I/O Pin
SS
Buffer
for more
Input
) to be
(1)
DD

Related parts for PIC18F25J50