English
Language : 

PIC18F6X2X Datasheet, PDF (113/386 Pages) Microchip Technology – 64/80-Pin High Performance, 64-Kbyte Enhanced FLASH Microcontrollers with A/D
PIC18F6X2X/8X2X
10.3 PORTC, TRISC and LATC
Registers
PORTC is an 8-bit wide, bi-directional port. The corre-
sponding Data Direction register is TRISC. Setting a
TRISC bit (= 1) will make the corresponding PORTC
pin an input (i.e., put the corresponding output driver in
a high-impedance mode). Clearing a TRISC bit (= 0)
will make the corresponding PORTC pin an output (i.e.,
put the contents of the output latch on the selected pin).
The Data Latch register (LATC) is also memory
mapped. Read-modify-write operations on the LATC
register, read and write the latched output value for
PORTC.
PORTC is multiplexed with several peripheral functions
(Table 10-5). PORTC pins have Schmitt Trigger input
buffers.
When enabling peripheral functions, care should be
taken in defining TRIS bits for each PORTC pin. Some
peripherals override the TRIS bit to make a pin an
output, while other peripherals override the TRIS bit to
make a pin an input. The user should refer to the
corresponding peripheral section for the correct TRIS
bit settings.
Note: On a Power-on Reset, these pins are
configured as digital inputs.
The pin override value is not loaded into the TRIS reg-
ister. This allows read-modify-write of the TRIS register
without concern due to peripheral overrides.
RC1 is normally configured by configuration bit,
CCP2MX, as the default peripheral pin of the CCP2
module (default/erased state, CCP2MX = 1).
EXAMPLE 10-3: INITIALIZING PORTC
CLRF
CLRF
MOVLW
MOVWF
PORTC
LATC
0xCF
TRISC
; Initialize PORTC by
; clearing output
; data latches
; Alternate method
; to clear output
; data latches
; Value used to
; initialize data
; direction
; Set RC<3:0> as inputs
; RC<5:4> as outputs
; RC<7:6> as inputs
FIGURE 10-8:
PORTC BLOCK DIAGRAM (PERIPHERAL OUTPUT OVERRIDE)
PORTC/Peripheral Out Select
Peripheral Data Out
RD LATC
Data Bus
WR LATC or
WR PORTC
WR TRISC
RD TRISC
Peripheral Output
Enable(2)
D
Q
CK Q
Data Latch
D
Q
CK Q
TRIS Latch
RD PORTC
Peripheral Data In
0
VDD
P
1
N
TRIS
VSS
Override
Logic
Schmitt
Trigger
Q
D
EN
Note 1: I/O pins have diode protection to VDD and VSS.
2: Peripheral output enable is only active if peripheral select is active.
I/O pin(1)
TRIS OVERRIDE
Pin Override
RC0
Yes
RC1
Yes
RC2
Yes
RC3
Yes
RC4
Yes
RC5
Yes
RC6
Yes
RC7
Yes
Peripheral
Timer1 OSC for
Timer1/Timer3
Timer1 OSC for
Timer1/Timer3,
CCP2 I/O
CCP1 I/O
SPI/I2C
Master Clock
I2C Data Out
SPI Data Out
USART1 Async
Xmit, Sync Clock
USART1 Sync
Data Out
 2003 Microchip Technology Inc.
Advance Information
DS39612A-page 111