External Links

Creative Science Centre

 

Library_pps

// #include "http://www.byvac.com//mBlib/flb/Library/2016/lib_pps.bas"

Peripheral Pin Select (PPS) Applies to MX170 & MX370

This map refers to the MX170 devices. The SMD version of the MX170 also has port C shown in grey

  Peripheral Pin
Inputs INT4,T2CK,IC4,SS1, PRA0  PRB3  PRB4  RB15  RB7  RRC7  RRC0  RRC5 
Outputs U1TXs,U2RTSs,SS1s,OC1s,C2OUTs
Inputs INT3,T3CK, IC3,U1CTS,U2RX,SDI1 PRA1  PRB5  PRB1 RRB11 RRB8 RRA8 RRC8 RRA9
Outputs SDO1s,SDO2s,OC2s
Inputs INT2,T4CK,IC1,IC5,U1RX,U2CTS,SDI2,OCFB PRA2 PRB6 PRA4 RB13 RB2 PRC6 PRC1 PRC3
Outputs SDO1s,SDO2s,OC4s,OC5s,REFCLKO
Inputs INT1,T5CK,IC2,SS2,OCFA PRA3 PRB14 PRB0 PRB10 PRB9 PRC9 PRC2 PRC4
Outputs U1RTSs,U2TXs,SS2s,OC3s,C1OUTs

This map refers to the MX370 devices. ** NOTE RPxx, above table uses PRxx

  Peripheral Pin          
Inputs INT3,T2CK,IC3,U1RX,U2RX,U5CTS,REFCLKI RPD2 RPG8 RPF4 RPD10 RPF1 RPB9 RPB10 RPC14 RPB5 RPF2
Outputs U3TXs,U4RTSs,SD02s,OC3s,C2OUTs
Inputs INT4,T5CK,IC4,U3RX,U4CTS,SDI1,SDI2 RPD3 RPG7 RPF5 RPD11 RPF0 RPB1 RPE5 RPC13 RPB3 RPF3
Outputs SD02s,U2TXs,U1TXs,U5RTSs,SD01s,OC4s
Inputs INT2,T4CK,IC2,IC5,U1CTS,U2CTS,SS1 RPD9 RPG6 RPB8 RPB15 RPD4 RPB0 RPE3 RPB7 RPB2  
Outputs SDO1s,U3RTSs,U4TXs,REFCLK0s,U5TXs,SS1s,OC5s,C1OUTs
Inputs INT1,T3CK,IC1,U3CTS,U4RX,U5RX,SS2,OCFA RPD1 RPG9 RPB14 RPD0 RPD8 RPB6 RPD5      
Outputs SD01s,U5TXs,U2RTSs,U1RTSs,SS2s,OC2s,OC1s

Special NOCONNECTs (see pps_out)

NOTES: The above are constants and should be prefixed with '*' when used in the pps functions, notice also that the output peripheral constants have a 's' postfix.

This function associates an input peripheral to a pin

pps_in(*peripheral(), *pin())

This function associates an output pin to a peripheral

pps_out(*pin(), *peripheral())

There is a special peripheral called NOCONNECTs. This is to disconnect an output peripheral as one output peripheral can be directed to more than one port. This is particularly useful for redirecting UART2.

How to Use

Example 1: Set up external interrupt 2, which is an input to be on RA4

pps_in(*INT2(), *PRA4()) // that's it, you will still need to set up the interrupt

Example 2: On all the boards UART1 is left for the user to use as UART is used for the main communication with the IC. So on the MX1 device we can set up on a choice of pins:

pps_out(*PRA0(), *U1TXs())
pps_in(*U1RX(), *PRA2())

The above will have U1TX coming out of pin RA0 and the input to the UART will be on pin RA2

HOT TIP
To use meaning full names when using the PPS a similar syntax is used as for the ports above. As an example, using the MX370 table setting up UART1 on port D2 and D3 could be:

pps_in(*U1RX(),*RPD2())
pps_out(*RPD3(),*U1TXs())

A better way is to define the port and pins as a constant, then it is easy to change them if required.

constant   RX   {RPD2(0),RPD2(1)}
constant   TX   {RPD3(0),RPD3(1)}

pps_in(*U1RX(),*RX())
pps_out(*RPD3(),*TX())