Tips for using dsPIC33e series MCU’s remappable peripheral IO

A big improvement of dsPIC33e series micro-controller from its predecessors is the re-mappable peripheral IO. This allows great flexibility for circuit board design, but also requires slightly more efforts to use it.

  • “RPn” is for both output and input, whereas “RPIn” is input only. When wiring up your PCB design, you need to double check that “PRIn” is not hookup up as a peripheral output.
  • Declaration for output type IO is different from input. For example, if you use RPI16 as input for UART1 receiver, you should claim in your program like:
    // U1ART RX connects to RPI16
    _U1RXR = 16;

    If you use RP118 as output for UART1 transmitter, you will need to claim in a reversed way like:

    // RP118 connects to peripheral 0b00001
    _RP118R = 1; // 0b00001 stands for UART1

    I believe it is related to the way the look-up table is implemented.

  • Configuring the peripheral IO register is not the whole story to correctly use an IO, especially when this pin shares with an analog function (usually ADC). All the IO that are shared with “ANx” are set to be an analog pin as default. Any attempts trying to use them as digital IO must have their corresponding ANSELx register cleared. (set to 0).
    For example, if you want to use Pin No.3 (which is also AN29, RE5, RP85) for any peripheral function’s output (UART, DCI, SPI, I2C, etc.,), you must declare:

    // ANSxy, x stands for Port A/B/C/D/E/..., y stands for number
    _ANSE5 = 0; // Enables digital port pin


    Update on 11/25/2013
    Pins that multiplex with analog function are not only limited to ADCs, but also Comparators/Op-Amps.  I/Os such as RG6, RG7 share with C1IN3- and C1IN1- are also default as analog pin after reset. In order to use them as digital I/O, their corresponding ANSxy (in this case _ANSG6, _ANSG7) register must be cleared. I didn’t realized this until I ran into trouble when remapping the DCI CSDI on one of the comparator input pin, and ended up receiving nothing but zero. As soon as I clear the corresponding ANSELx register, data started pumping into the DCI receiver.

2 Replies to “Tips for using dsPIC33e series MCU’s remappable peripheral IO”

  1. Hi,

    The article helped me to understand the concept of peripheral multiplexing , thanks for sharing.
    Could you explain the same concept in context of dsPIC33e QEI configuring for Position counter as well as input capture. My application is to find low speed calculation using a 1000 ppr encoder.


  2. As for the “Why are outputs configured the other way round compared to inputs”, it’s because everything can have multiple effects, but only one cause.

    Take any input. You can assign this input to as many peripherals as you want. But every peripheral can only be fed by one input signal.

    Outputs have to be different because you can’t have several peripherals fight each other who’s to set or clear the pin. But you can have several pins all reflect the result of the same peripheral (e.g. to get more milliamperes into an LED without external circuitry at the cost of more pins).

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.