Home > Electronics > Peripheral Pin Select (PPS) (using XC16 and MPLAB X)

Peripheral Pin Select (PPS) (using XC16 and MPLAB X)

Peripheral Pin Select or PPS use to be a feature available only in 16 bit and 32 bit PICs, but now its available in some 8bit.

Peripheral Pin Select is like having some blank pins that can be assigned as a peripheral pin like UART, PWM, external timer clock and so on of the given choices from the datasheet.

 

Documents to read

 

Example PPS

I am using the part dsPIC33FJ128GP202 (28pin package). If I look at the pin diagram, I got 16 Reprogrammable Pins (RP0 – RP15). That’s a lot! Some of them are 5V tolerant which is very important if you are going to hook up a sensor that is giving a 5V signal output.

    PPSPins
Note: Pin out I/O Descriptions table (Table 1-1) gives the list of peripheral pin names and PPS functionality.

Table 1-1 (pin out I/O descriptions) of dsPIC33FJ128GP202

PPSDesc

The pins marked here are not listed in the pin diagram. So PPS feature can be used to assign peripheral pin functions.

 

PPS Sample Code

 

Steps to use PPS functionality with macro’s

  1. include pps.h
  2. unlock pins with “ PPSUnLock “ macro
  3. PPSInput or PPSOutput function to assign pin (check below for more details)
  4. Lock pins with “ PPSLock “

If the pin is assigned as an input pin  use PPSInput() function, say RX pin of UART assigned to RP7 (pin 16 according to the pin diagram give above). Then the code will look like

PPSInput(IN_FN_PPS_U1RX, IN_PIN_PPS_RP7);

If the pin is assigned as an output pin use PPSOutput() function, say PWM 1 assigned to RP9 (Pin 18 according to the pin diagram given above), then the code will look like

PPSOutput(OUT_FN_PPS_OC1,OUT_PIN_PPS_RP9);

 

Given below is the sample to properly assign pins with unlock and lock macro’s.

 

/* * File: dsPICtest.c * Author: Singular Engineer * * Created on January 9, 2015 */ #define FCY 40000000ULL //Fcy = (Fosc/2); Fosc = 80MHz #define _ISR_PSV __attribute__((__interrupt__, __auto_psv__)) #include <xc.h> #include "config.h" #include <libpic30.h> #include <pps.h> #include <outcompare.h> //for PWM #include <uart.h> unsigned int i = 0; void SetupClock(void); int main(int argc, char** argv) { SetupClock(); TRISBbits.TRISB0 = 0; //RB0 as output LATBbits.LATB0 = 1; //Turn on the led/RB0 //---------- Assigning PPS function------------------ PPSUnLock; PPSOutput(OUT_FN_PPS_OC1,OUT_PIN_PPS_RP9); PPSInput(IN_FN_PPS_U1RX, IN_PIN_PPS_RP7); PPSLock; //----------------------------------------------------- while(1) { } return 0; } void SetupClock() { //Setting N1 to 4 (N1 = n+2); n = N1-2 CLKDIVbits.PLLPRE0 = 0; CLKDIVbits.PLLPRE1 = 1; CLKDIVbits.PLLPRE2 = 0; CLKDIVbits.PLLPRE3 = 0; CLKDIVbits.PLLPRE4 = 0; //Setting M to 32 (M = m+2); m = M-2 PLLFBDbits.PLLDIV0 = 0; PLLFBDbits.PLLDIV1 = 1; PLLFBDbits.PLLDIV2 = 1; PLLFBDbits.PLLDIV3 = 1; PLLFBDbits.PLLDIV4 = 1; PLLFBDbits.PLLDIV5 = 0; PLLFBDbits.PLLDIV6 = 0; PLLFBDbits.PLLDIV7 = 0; PLLFBDbits.PLLDIV8 = 0; //Setting N2 to 2 CLKDIVbits.PLLPOST0 = 0; CLKDIVbits.PLLPOST1 = 0; }

  1. June 22nd, 2019 at 15:01 | #1

    Very good post. I absolutely love this website. Thanks!

  2. June 22nd, 2019 at 12:26 | #2

    Gently press with a towel to remove excess water.
    Do not rub or wring.Dry condition Dry condition Place on a folding wig stand, spray with a Leave in Conditioner,
    and allow to air dry. DO NOT WRING OR SQUEEZE.Styling the HairUse your fingers or a wide tooth comb to style your
    synthetic wig.

    tape in extensions I glad to see they improving, honestly, since we
    watch pretty much the whole thing every day.I held my tongue
    on being critical of other events before only to see them blow up later
    (the beach anyone), so this time I said something which I hope they use to improve their
    broadcast. EVO doesn benefit if ELeague fails, and ELeague success in no way detracts from
    EVO. But the FGC OGs seem like they are entitled to enforce the “right”
    way to represent the FGC when even they have not figured out what that is exactly they are constantly dancing around the thuggery/pg 13 “professionalism” line like headless chickens.tape in extensions

    U Tip Extensions At her personal site, she explains that the phrase is not only a funny phrase from the past, but it
    also reflects what she would like people to feel when they watch her
    videos, hoping they will “slip into happiness” while watching.[13]Her first sketch,
    Instant vlogging,[14] was originally broadcast on September 6, 2006 and featured Gambito impersonating four different
    characters, each representing a different video blogging style.
    Due to the positive response she received from the YouTube community, two of those characters (the teenager and the girl in the “soap opera” style) were explored
    further in the following videos, the latter becoming
    the first episode of a soap opera hair extensions spoof featuring two twin sisters both interpreted by Gambito.
    Her second video introduced many of the recurring themes in her following sketches, such as her parents’ attitude towards her growing popularity over
    the Internet and her family’s ethnic habits seen through the mind
    of an American.U Tip Extensions

    hair extensions From invading boy’s clubs, to needling male chauvinistic ego bubbles, women across the
    world have done it all. However, there is a vast section of
    women living in impoverished conditions in underdeveloped countries with minimal rights and excessive
    duties. It’s time to awaken them, now.hair extensions

    360 lace wigs Leave in hair for several hours or over night.
    For extra curly hair add more braids and curlers. Your hair may resemble a
    perm, but will be very healthy and beautifully curly. If you dont like the way I do it, feel
    free to use this for inspiration. The length of this project depends on the size of horns.

    Smaller horns (Karkat, Sollux, Terezi) take only 2 4 hours, while bigger horns (Tavros, Gamzee, Aradia) can take up to a day or
    two 360 lace wigs..

  3. June 11th, 2019 at 02:20 | #3

    Another unusual birthday present thought for men is a little left of middle.
    Vans shoes company provides a vast vary of styles for
    individuals of all ages in the Vans men sneakers
    and Vans girls sneakers collections. Just Converse and Skechers offer cute, up to the minute sneakers and canvas shoes with
    a unique twist in model. Baberoo Organic Cotton Socks (which have the extra advantages of being environmentally friendly and made from organic
    cotton) offer a cute set of purple, green, yellow, and
    blue clogs printed on white socks. Crocs also are available all the good vivid colours of the season and there’s a selection for all the family and
    Crocs provide value for cash. Nearly each womens shoe
    sort must now come in the ‘Mary Jane’ style. Almost any
    ‘conventional’ womens shoes now comes with a
    ‘peep toe’ type as well as new peep toe booties and the standard type oxford style peep toe footwear and boots.
    The sky actually is the limit relating to womens shoes.
    Shoes are great and can give away a lot about somebody’s character.

  4. Arjun
    April 26th, 2017 at 06:14 | #4

    Great Tutorial. Thank you. It was much simple to understand and follow. Better than any datasheet tutorial.

  1. No trackbacks yet.