Confused on Microchip's Peripheral Pin Select registers.

Discussion in 'Embedded Systems and Microcontrollers' started by spinnaker, Oct 22, 2015.

  1. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    I am a little confused on Confused on Microchip's Peripheral Pin Select. Am I right in assuming that if I wanted RP10 as the INT1 pin, I would set RPINR1 to xA?

    upload_2015-10-22_17-47-31.png
     
  2. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,321
    889
    Probably not. Somewhere in the data sheet following the section you showed, there should be a table, probably titled, "INPUT PIN SELECTION FOR SELECTABLE INPUT SOURCES" that gives the actual correspondence between PPS Input Register settings and the various RPx or RPIx pin designations. For the dsPIC33EP part I'm currently working with, in the datasheet there is a hyperlink to that table, immediately following the section you illustrated above.
     
  3. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    That is why I am confused. There is indeed a table but it only lists the various peripherals like SPI, EUSART, ECPP etc. It does not mention INT1 or INT2.

    That table precedes the section I posted.
     
  4. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,321
    889
    Which processor? I'll see what I can figure out...
     
  5. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,061
    3,823
  6. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    Yeah thanks, I have seen that. What I am trying to do is figure out how to set the register.
     
  7. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,321
    889
    Yes, I'm aware of that. But when it says, "Pins that support the peripheral pin select feature include the designation, 'RPn', in their full pin designation, where 'RP' designates a remappable peripheral and 'n' is the remappable pin number," that does not mean that the 'n' in 'RPn' is the number that should be loaded into the PPS register; to translate 'RPn' into the actual PPS register load value you need to consult the table in the specific device data sheet, since the table is different for each chip.
     
  8. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015

    As I posted above there is no table for INT1, just the traditional peripherals.

    I was just about to wire things up and try it.
     
  9. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,321
    889
    The table I referred to above is NOT a table specific to any peripheral or peripheral function; it is a translation table mapping between peripheral pin select register values (i.e., the number you should load into the PPS register) and RPn designations, and it applies to ALL remappable inputs. You can't just take the "n" in "RPn" and load it into the register.

    Look again for the table, in the device data sheet (not the family reference manual); I guarantee you, it's there somewhere.
     
  10. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    Think I found it but not sure I understand it. How do I map RP0 for INT1?

    upload_2015-10-22_21-5-39.png
     
    Last edited: Oct 22, 2015
  11. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    Found a sample in the datasheet. Looks like I was correct.

    RPINR1 = 21;// INT1 mapped to RP21 (RD4)
     
  12. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,321
    889
    All you can do is try it and see, I guess. Without knowing the part you're working with so I can look at its datasheet myself, I can't help you much.

    All I know is that for the part I'm using (dsPIC33EP64GP502), it's not as simple as what you're describing: you have to go to the table (table 11-2 on p. 178 of the datasheet) to find the PPS register value for the the particular RP/RPI you're looking for.
     
  13. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    Now I can't get any of the pins working as a freaking input! ;) Works as an output just not as an input. I am sure it is something stupid, I have done this a hundred times.

    This is what I see on 178

    upload_2015-10-22_21-59-57.png
     
  14. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    Should have mentioned the chip. This is a pic18f26J53. This is a strange one probably why I can't get the pin to work as a binary input. Probably something to do with disabling the analog.
     
  15. spinnaker

    Thread Starter AAC Fanatic!

    Oct 29, 2009
    4,887
    1,015
    I need to set the ANCON0 register but time for sleep. :)
     
  16. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,321
    889
    OK, reading your datasheet I can see the source of the confusion: apparently, PPS is done a bit differently in the PIC18F and dsPIC33EP parts. For the PIC18F, you and GopherT are correct: the "n" in "RPn" is indeed the actual number you load into the RPINR register.

    But in the dsPIC33EP part I'm using, that is not the case because there is an additional level of mapping in the form of that table I referred to, because the dsPIC33EP parts feature what Microchip calls "virtual connections" wherein peripheral inputs can be connected not just to RP/RPI pins, but also to the outputs of other peripherals on the chip without ever going through a pin. Hence the need for the translation table, because of all the extra choices.

    Sorry for the confusion. You were talking about apples, and I was assuming oranges...
     
Loading...