top of page

Using the Signal Routing Port for a Shift Register on the PIC18-Q71 Family of Microcontrollers

This blog post introduces the new Signal Routing Port (SRPORT) peripheral integrated onto the PIC18-Q71 family of microcontrollers (MCUs) and future devices. We will discuss how the SRPORT can be used in conjunction with other peripherals to implement a Serial-In Parallel-Out (SIPO) shift register.



Understanding the Issue


In MCUs with limited I/O pins, pin availability often becomes a main system constraint. Oftentimes there is a tradeoff between the number of available pins and the cost, size and complexity of the chip itself, making it difficult to find that perfect balance. Applications that involve the interconnection of multiple peripherals often encounter the issue where not all peripheral signals can directly interconnect with one another, requiring the signals to be routed via external I/O pins to establish that connection. This may not be ideal as it limits the MCU’s ability to interface with multiple external components if needed, thus reducing the overall functionality of the system.


There are solutions to that situation, such as using a higher-pin count device to ensure all connections can be made, or adding additional hardware, such as an I/O expander, to increase the number of pins available. Although these solutions may seem viable, it is important to understand the tradeoffs as they could add complexity to the system, increasing overall cost.


What Is the Signal Routing Port?


The SRPORT is a software interface that imitates the physical hardware ports on a microcontroller, essentially acting like a regular I/O port that is not physically connected to an external pin. This allows for communication with the device as if it were connected to a physical port on the microcontroller, eliminating the need to use any additional physical I/O lines in your application. The SRPORT brings advanced interconnectivity to designs which ultimately minimizes the need for external pin routing. This allows users to create custom configurations without complex software development or extensive PCB modifications.


The SRPORT module is a versatile hardware solution comprised of eight virtual input and eight virtual output pins. These pins are extremely flexible to match specific application needs. Each signal routing pin offers a range of input selections including outputs of various core independent peripherals which allows for a hardware-based solution for exchanging data between selected peripherals and a virtual pin.


For applications that require advanced synchronization and timing, the SRPORT offers a wide selection of clock sources, including those from peripherals. Each signal routing pin is equipped with a flip-flop to aid in the synchronization of signals if needed, ultimately aiding in the design of hardware-based state machines.


The SRPORT serves as a high-level input selection multiplexer, connecting digital peripheral outputs to inputs of other peripherals internally through Peripheral Pin Select (PPS) eliminating the need to route these signals to external I/O pins for communication between peripherals. The range of input selections also includes the output of the immediate next signal routing pin as an input. This used in conjunction with the flip-flop that each signal routing pin offers allows for shift register operations. Lastly, the SRPORT offers dedicated Interrupt-on-Change. This is useful when used with trigger events for or from other peripherals such as the DMA controller or the Analog-to-Digital Converter.


If you are interested in learning more about the SRPORT, check out the overview video and the landing page.


Using the SRPORT to Create a Serial-In Parallel-Out (SIPO) Shift Register


Now that we have a good understanding of the SRPORT, we will now discuss how our Applications team implemented a SIPO shift register using the SRPORT and other peripherals.


This application uses a Curiosity High Pin Count (HPC) board with a PIC18F46Q71 microcontroller.


A high-level block diagram of how the code example operates is shown below.



What Is a Serial-In Parallel-Out (SIPO) Shift Register?


A shift register is a type of digital circuit that can store and transfer binary data. A shift register consists of multiple flip-flops cascaded with one another where each flip-flop can store a single bit of data and the entire chain can store multiple bits of data.


A SIPO shift register is a digital circuit that can store and transfer data in a series of flip-flops. It receives data one bit or byte at a time through a serial input and outputs the entire set of bits or byte in parallel. A SIPO shift register typically consists of multiple flip-flops interconnected with one another, using their data and clock signals as inputs.


A basic representation of a SIPO shift register is shown below.



Theory of Operation


Let’s begin by discussing what role the SRPORT must play in this shift register example. The SRPORT module is responsible for storing and shifting data based on an incoming clock signal. To configure the SRPORT as a shift register, the SRPORT allows one of its input selection options to be the output of the immediate next signal routing pin as an input.


A graphical representation of this is shown below.



The SRPORT derives its clock signal and data from the Pulse Width Modulator (PWM) peripheral(s). The PWM1 module generates a 1 kHz clock signal to be used as the clock input for the SRPORT. To utilize this signal as the SRPORT’s clock signal, a Configurable Logic Cell (CLC) is used to redirect the clock signal into the SRPORT’s clock input selection.


The PWM2 module is used to generate a data signal to be used as an input of the shift register. The data generated by the PWM2 is shifted and stored at each rising edge of the 1 kHz clock signal. Once eight clock cycles have occurred, an 8-bit value representing the data from the preceding eight clock cycles is stored in the PORTW register. Once the eighth clock cycle occurs, the Universal Timer (UTMR) triggers a Direct Memory Access (DMA) transfer to move the data from the SRPORT to RAM. Subsequently, another DMA module is employed to move the data from RAM to a UART’s transmit buffer to be visualized on a data terminal.


Lastly, the on-board push button is used on the Curiosity HPC development board to start each round of the transmission of data. To account for the push button to have potential debouncing, the Timer2 module was used in conjunction with the CLC module to create a hardware-based code-free button debounce solution.


In conclusion, this demonstrates the utilization of the SRPORT along with other core-independent peripherals to effectively implement a shift register. For further insights into the demonstration, you can explore the MPLAB Discover link, which guides you through the MPLAB Code Configurator (MCC) setup of the project. For more information about the SRPORT, visit the peripheral landing page.


Ethan Layton, Feb 15, 2024

Tags/Keywords: Industrial and IoT




7 visualizações0 comentário

Posts recentes

Ver tudo

Yorumlar


bottom of page