Im new to PIC. Im working on PIC24FJ64GA002 PIC. Can any one pls explain how below code says "set RP10 to external interrupt"?

                   `RPINR0  =   0x0A00;`

I have gone through "PERIPHERAL PIN SELECT REGISTER MAP" from datasheet, RPINR0 register didnt mention RP10. RPOR5 has mentioned RP10 only.



1 Answer 1


From the PIC24FJ64GA004 Family Reference Manual Input Mapping The inputs of the Peripheral Pin Select options are mapped on the basis of the peripheral; that is, a control register associated with a peripheral dictates the pin it will be mapped to. The RPINRx registers are used to configure peripheral input mapping (see Register 10-1 through Register 10-14 ). Each register contains two sets of 5-bit fields, with each set associated with one of the pin-selectable peripherals. Programming a given peripheral’s bit field with an appropriate 5-bit value maps the RPn pin with that value to that peripheral. For any given device, the valid range of values for any of the bit fields corresponds to the maximum number of Peripheral Pin Selections supported by the device.

RPINR0 is the input control register for External Interrupt 1 (INT 1). PRINR0 is a 16 bit register, with bits 8 to 12 actually implemented. Those 5 bits controls which pin can drive External Interrupt 1.

Here's the register definition from the family reference manual.

enter image description here

The desired pin number gets written to the register. For example, if I wanted to map RP1 to External Interrupt 1 (INT1), I would do this:

RPINR0 = 0x0100.

This will assign the decimal value of 1 to the top byte of the RPINR0 of the special function register, which will map the RP1 pin to the External Interrupt 1 (INT1) module.

Assuming INT1 is configured correctly in your case, when some external device wiggles RP10, the hardware will trigger the INT1 interrupt, at which point the firmware can decide what to do with it through an interrupt service routine.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.