• AVR Freaks

Hot!About Remappable pins

Author
AKJ
Starting Member
  • Total Posts : 49
  • Reward points : 0
  • Joined: 2019/05/27 06:55:52
  • Location: 0
  • Status: offline
2019/08/07 02:08:24 (permalink)
0

About Remappable pins

Hello,
I have questions concerning remappable pins. The documentations of the controller do not seem (at least for me) to give clearer details. Answers to these questions would be nice (for the dsPIC33EP512GM706, documentations ):
 
1. If i were to connect PIN5 from the controller (RG7/ AN18/ RPI119) to DI, PIN8 (RG9/AN16/RPI121) to CS, PIN4 (RG6/AN19/RP118) to SCLK and PIN6 (RG8/AN17/RP120) to DO, would i be able to use the SPI2 protocol, if i were to switch these pins?
2. How do i remap pins? Following the example on page 116, this should change the input pin
RPINR22 = 0x7700; // 111 0111 // Connect the SDI2 input RPI119

but how do i remap the output pins and enable them?
 
Thanks.
#1

3 Replies Related Threads

    ric
    Super Member
    • Total Posts : 24333
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: About Remappable pins 2019/08/07 02:21:30 (permalink)
    0
    AKJ
    ...
    1. If i were to connect PIN5 from the controller (RG7/ AN18/ RPI119) to DI, PIN8 (RG9/AN16/RPI121) to CS, PIN4 (RG6/AN19/RP118) to SCLK and PIN6 (RG8/AN17/RP120) to DO, would i be able to use the SPI2 protocol, if i were to switch these pins?

    Yes

    2. How do i remap pins? Following the example on page 116, this should change the input pin
    RPINR22 = 0x7700; // 111 0111 // Connect the SDI2 input RPI119

    but how do i remap the output pins and enable them?

    Inputs and outputs work differently.
    For inputs, you write to a register dedicated to an input function (e.g. RPINR22 is for SDI2), and write a value to say which pin it takes the input from. It is possible for multiple peripherals to all use the same pin as input.
     
    For outputs, you write to a register dedicated to a pin, and write a value to select which output function is connected to that pin. It is possible to have multiple pins all outputting the same signal.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #2
    AKJ
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/05/27 06:55:52
    • Location: 0
    • Status: offline
    Re: About Remappable pins 2019/08/07 02:52:34 (permalink)
    0
    ric,
     
    something like this?
     

    // Remap RP pins to input
    RPINR22bits.SDI2R = 0b1110111; // SDI2 uses RPI119,
    // Remap RP pins to ouput
    RPOR11bits.RP120R = 0b001000; // SDO2 uses RP120
    RPOR10bits.RP118R = 0b001001; // SCK2 uses RP118

     
    Shoudn't PIN8 (RG9/AN16/RPI121) to CS be an output mappable pin instead?
     
    Thanks for the reply.
    #3
    AKJ
    Starting Member
    • Total Posts : 49
    • Reward points : 0
    • Joined: 2019/05/27 06:55:52
    • Location: 0
    • Status: offline
    Re: About Remappable pins 2019/08/07 03:06:39 (permalink)
    0
    ric,
     
    could slave select be:

    RPINR23bits.SS2R = 0b1111001; // SS2 uses RPI121

     
    I decided to set those pins to digital and force them to be input/output (as the documentation mentioned, TRIS have priority over RP)\
    The resulting code is:

    // Remap RP pins to input
    RPINR22bits.SDI2R = 0b1110111; // SDI2 uses RPI119,
    RPINR23bits.SS2R = 0b1111001; // SS2 uses RPI121
    // Remap RP pins to ouput
    RPOR11bits.RP120R = 0b001000; // SDO2 uses RP120
    RPOR10bits.RP118R = 0b001001; // SCK2 uses RP118

    TRISGbits.TRISG7 = 1;
    TRISGbits.TRISG8 = 0;
    TRISGbits.TRISG6 = 0;
    TRISGbits.TRISG9 = 0;

    ANSELG = 0;

    // SPI2 Implimentation here

     
    What do you think? Can i proceed to setting up the SPI configurations?

    Thanks for the reply.
     
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5