3.1 Internal Peripheral Connection
A common application use case involves connecting one peripheral output to the input of another peripheral. While some peripherals can choose from an exhaustive list of peripherals in the input selection multiplexer, many others have a limited selection of peripherals. In the latter case, traditional solutions include using external I/O pins to interconnect two peripherals through a wire or jumper.
This not only consumes more power and reduces the speed of the application but also uses up multiple I/O pins, which are a valuable resource, especially in low pin count devices. In devices with the Signal Routing Port module, signal routing port pins can be used to interconnect peripherals instead of external I/O pins. This reduces power consumption, increases the speed of the application, and frees up valuable I/O pins for other purposes.
For example, in most devices, the SPI1 Serial Clock Input (SPI1_SCK) is only available as a PPS input through a physical I/O pin and does not have an input selection multiplexer. Applications that require the SPI to be triggered in Client mode by an internal timer rather than an external clock will need to use two external I/O pins to connect the output of the timer to the SPI clock input, as shown in Peripheral Interconnect without Signal Routing Port.
Peripheral Interconnect without Signal Routing Port
// Output Peripheral: Universal Timer TU16A Pulse Output // Input Peripheral: SPI1 Clock Input in Client Mode // Note: Initialization routines are not shown void Interconnect_IOPort() { // Set RC0 as TU16A PPS output RC0PPS = 0x24; // 0x24 = TU16A_OUT on PIC18F46Q71 // Set RC3 as SPI1 SCK PPS input SPI1SCKPPS = 0x13; // 0x13 = RC3 on PIC18F46Q71 // Physically connect RC0 and RC1 with a jumper = :( }
When using a Signal Routing Port, the timer output can be connected directly to the SPI clock input using a signal routing port pin without sacrificing two physical I/O pins, as shown in Peripheral Interconnect with Signal Routing Port.
Peripheral Interconnect with Signal Routing Port
// Input to SRPORT (Output Peripheral): Universal Timer TU16A Pulse Output // Output from SRPORT (Input Peripheral): SPI1 Clock Input in Client Mode // Note: Initialization routines are not shown void Interconnect_SRPORT() { // Set RW0 input as TU16A_OUT PORTWIN0 = 0x04; // 0x04 = TU16A_OUT on PIC18F46Q71 // Set RW0 as SPI1 SCK PPS input SPI1SCKPPS = 0x38; // 0x38 = RW0 on PIC18F46Q71 // No physical interconnection necessary = :) }