Read the Data Sheet section about PPS (Peripheral Pin Select) (Section 10.4 of the current Data Sheet for your chip).
Table 10-2 shows what registers are used for the various input pin functions. In a given register, put the number of an
RPn pin in the bit positions for that function.
Table 10-3 shows what function numbers to assign to registers for PPS pins used as outputs. In a given register (for the particular
RPn pin), put the function number shown in that table.
Look at the rest of that section to see the register designations for the given
RPn Input and Output stuff.
Here is code used in my PIC24FJ32GB002 project (same assignments work for '64GB002):
I used RP8 for the Uart1 Receive pin and RP7 for Uart1 Transmit. After reading the section in the Data Sheet you should be able to change the assignments to suit your requirements.
// For PIC24FJ34GB002/PIC24FJ64GB002
//
// Configure Input Functions (Table 10-2)
// Assign U1RX To Pin RP8 (Pin 17 on the DIP-28)
RPINR18bits.U1RXR = 8;
// Configure Output Functions (Table 10-3)
// Assign U1TX (Function 3) to Pin RP7 (Pin 16 on the DIP-28)
RPOR3bits.RP7R = 3;
Now, some would recommend using assignments with macros defined in <PPS.H>, and I think that's probably a Good Idea in the long run, but I think it's important to be able to use explicit register assignments, at least for the first time, so that you can really understand the mechanism. (You have to look at the data sheet anyhow to understand what pins are programmable.)
Namely:
1. For input functions, there is a register for that function and you put the programmable pin (
RPn) number in that register. Use any
RPn that is defined for the device. Some devices have
RPIn pins defined. These can only be used for inputs.
2. For output functions, there is a function number that you put into the appropriate register for that output pin. Use any
RPn that is defined for the device.
Summary:
For an input, you assign a PPS pin to a register defined for a specific function.
For an output, you assign a function number to a register defined for a specific PPS pin.
For your question abour RB5:
Pin 14 (RB5) does not have an
RPn designation (so it is not a PPS pin), therefore it can
not be used for any of the programmable I/O functions.
Regards,
Dave
post edited by davekw7x - 2015/02/24 13:03:08