24fj PPSApNote
24fj PPSApNote
HIGHLIGHTS
This section of the manual contains the following topics:
Note: This family reference manual section is meant to serve as a complement to device
data sheets. Depending on the device variant, this manual section may not apply to
all dsPIC33/PIC24 devices.
Please consult the note at the beginning of the “I/O Ports” chapter in the current
device data sheet to check whether this document supports the device you are
using.
Device data sheets and family reference manual sections are available for
download from the Microchip Worldwide Website at: http://www.microchip.com
1.0 INTRODUCTION
The general purpose I/O pins can be considered the simplest of peripherals. They allow the PIC®
MCU to monitor and control other devices. To add flexibility and functionality to a device, some
pins are multiplexed with alternate function(s). These functions depend on which peripheral
features are on the device. In general, when a peripheral is functioning, that pin may not be used
as a general purpose I/O pin.
Most of the dsPIC33/PIC24 devices support the Peripheral Pin Select (PPS) feature. The PPS
constitutes pins which users can map to the input and/or output of some digital peripherals.
Figure 1-1 shows a block diagram of a typical I/O port. This block diagram does not take into
account peripheral functions that may be multiplexed onto the I/O pin.
Open-Drain Selection
1
Data Bus D Q
WR TRISx CK Q
TRISx Latch
D Q
I/O Pin
WR LATx
CK
WR PORTx
Data Latch
Read LATx
Read PORTx
1 4
BSET PORTA, #1 instruction
BSET PORTA, #0 instruction
has finished execution. Voltage
has finished execution. Voltage
is starting to rise on I/O Pin 1
on I/O Pin 0 is starting to rise.
and fall on I/O Pin 0.
2
BSET PORTA, #1 instruction 3
I/O Pin 0 transitions from
starts execution and reads PORTA ‘0’ to ‘1’.
register (bit 0 is read as ‘0’).
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Refer to the specific device data sheet for the actual implementation.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Refer to the specific device data sheet for the actual implementation.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Refer to the specific device data sheet for the actual implementation.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Refer to the specific device data sheet for the actual implementation.
Open-Drain Selection
Peripheral Module Output Multiplexers
PIO Module 1
Read TRISx 0
Data Bus
D Q I/O Pin
WR TRISx
CK Q
TRISx Latch
D Q
WR LATx/
WR PORTx
CK
Data Latch
Read LATx
Read PORTx
Peripheral Input R
Legend: R = Input buffer type depends on the peripheral. For more information, refer to the specific product data sheet.
Open-Drain Selection
Peripheral Pin Select Output Multiplexers
Output Function
Select for the Pin
Data Bus
D Q
WR TRISx
CK Q
TRISx Latch
D Q
WR LATx/
WR PORTx
CK
Data Latch
Read LATx
Read PORTx
Peripheral Input
Pin Selection
I/O Pin 0
0
I/O Pin 1
Peripheral Input 1
I/O Pin n
n
U1RXR<5:0>
0
RP0
1
RP1
U1RX Input
to Peripheral
2
RP2
n
RPn
RPnR<5:0>
OC5 Output
22
//***************************
// Assign U1CTS To Pin RP1
//***************************
RPINR18bits.U1CTSR = 1; //’1’ represents RP1
//************************************************************
// Configure Output Functions
//************************************************************
//***************************
// Assign U1Tx To Pin RP2
//***************************
RPOR1bits.RP2R = 3; //’3’ represents U1TX
//***************************
// Assign U1RTS To Pin RP3
//***************************
RPOR1bits.RP3R = 4; //’4’ represents U1RTS
//************************************************************
// Lock Registers
//************************************************************
__builtin_write_OSCCONL(OSCCON | 0x40) //set the bit 6 of OSCCONL to
//lock Pin Re-map
//******************************************************************
//This code is used when interested in inline assembly. If this code is //
used then the above two lines should not be used for unlocking.
//******************************************************************
/*
asm volatile ( “push w1 \n”
“push w2 \n”
“push w3 \n”
"mov #OSCCON, w1 \n"
"mov #0x46, w2 \n"
"mov #0x57, w3 \n"
"mov.b w2, [w1] \n"
"mov.b w3, [w1] \n"
"bset OSCCON, #6 \n"
“pop w3 \n”
“pop w2 \n”
“pop w1”;
*/
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Here, ‘n’ represents the peripheral select input pin number.
2: Here, ‘x’ represents the Peripheral Pin Select Input register number and it varies from device to device.
Legend:
R = Readable bit W = Writable bit U = Unimplemented bit, read as ‘0’
-n = Value at POR ‘1’ = Bit is set ‘0’ = Bit is cleared x = Bit is unknown
Note 1: Here, ‘n’ represents the Peripheral Pin Select output pin number.
2: Here, ‘y’ represents the Peripheral Pin Select Output register number and it varies from device to device.
VDD
CN0PUE
(CNPU1<0>)
CN0 D Q
Pin
CN0PDE
(CNPD1<0>) C
CN0 Change
CN
Interrupt
D Q
CN0IE (CNEN1<0>)
CN1 Change
CN1-CNx
(details not
shown) CNx Change
A summary of the registers associated with the dsPIC33/PIC24 I/O ports is provided in Table 7-1, Table 7-2 and Table 7-3.
Table 7-2: Special Function Registers Associated with Peripheral Pin Selection(1)
All
Name Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 Bit 8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Resets
Table 7-3: Special Function Registers Associated with Change Notification Pins(1)
All
Name Bit 15 Bit 14 Bit 13 Bit 12 Bit 11 Bit 10 Bit 9 Bit 8 Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Resets
Note: Please visit the Microchip website (www.microchip.com) for additional application
notes and code examples for the dsPIC33/PIC24 families of devices.
• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
== ISO/TS 16949 ==