PIC12F1516 MICROCHIP [Microchip Technology], PIC12F1516 Datasheet - Page 113

no-image

PIC12F1516

Manufacturer Part Number
PIC12F1516
Description
28/40/44-Pin Flash Microcontrollers with nanoWatt XLP Technology
Manufacturer
MICROCHIP [Microchip Technology]
Datasheet
12.0
In general, when a peripheral is enabled, that pin may
not be used as a general purpose I/O pin.
Each port has three standard registers for its operation.
These registers are:
• TRISx registers (data direction)
• PORTx registers (reads the levels on the pins of
• LATx registers (output latch)
Some ports may have one or more of the following
additional registers. These registers are:
• ANSELx (analog select)
• WPUx (weak pull-up)
TABLE 12-1:
The Data Latch (LATx register) is useful for
read-modify-write operations on the value that the I/O
pins are driving.
A write operation to the LATx register has the same
affect as a write to the corresponding PORTx register.
A read of the LATx register reads of the values held in
the I/O PORT latches, while a read of the PORTx
register reads the actual I/O pin value.
The port has analog functions and has an ANSELx
register which can disable the digital input and save
power. A simplified model of a generic I/O port, without
the interfaces to other peripherals, is shown in
Figure
 2010 Microchip Technology Inc.
Device
PIC16(L)F1516/8
PIC16(L)F1517/9
the device)
12-1.
I/O PORTS
PORT AVAILABILITY PER
DEVICE
Preliminary
FIGURE 12-1:
EXAMPLE 12-1:
; This code example illustrates
; initializing the PORTA register. The
; other ports are initialized in the same
; manner.
BANKSEL PORTA
CLRF
BANKSEL LATA
CLRF
BANKSEL ANSELA
CLRF
BANKSEL TRISA
MOVLW
MOVWF
To peripherals
Write PORTx
Write LATx
Data Bus
PIC16(L)F1516/7/8/9
Read PORTx
PORTA
LATA
ANSELA
B'00111000' ;Set RA<5:3> as inputs
TRISA
Data Register
D
CK
Read LATx
ANSELx
GENERIC I/O PORT
OPERATION
INITIALIZING PORTA
Q
;
;Init PORTA
;Data Latch
;
;
;digital I/O
;
;and set RA<2:0> as
;outputs
TRISx
DS41452B-page 113
V
V
DD
SS
I/O pin

Related parts for PIC12F1516