AN03007: XCORE Ports£££doc/rst/an03007.html#an03007-xcore-ports

The XMOS XCORE processor can interface electrical signals on a package pin to signals in the processor through a highly efficient low-latency interface called a port.

Ports are the interface between th physical and the logical worlds. Their structure is shown in Fig. 1. On the left side a port is connected to a physical GPIO wire that can drive a signal at some voltage, or that can sample a signal. On the right side of the diagram, a port is connected to the execution unit where those voltage levels are represented by logical values: zero, one, or multi-bit values.

../../_images/port-structure.svg

Structure of a port

Between the GPIO pins and the execution unit is a set of components that can be used to serialise, deserialise, buffer, and clock data.

This document provides an overview of the capabilities of XCORE ports and the options available for system designers. It is intended to provide a starting point for understanding the capabilities of the XCORE ports, and provides links to more detailed information on the various aspects of port operation. The following application notes describe port operations in detail:

This document shows how these application notes relate to each other.

AN03007: XCORE Ports$$$Ports and How to Programme Them£££doc/rst/an03007.html#ports-and-how-to-programme-them

A port provides the interface between the processor and its environment. The port logic can drive its pins high or low, or it can sample the value on its pins, optionally waiting for a particular condition. Ports are not memory mapped; instead they are accessed using dedicated instructions. Each XCORE port operates autonomously as a small state machine that can provide deterministic, hardware-timed processing of signals, ensuring that the signals can be operated on in real-time with low latency.

By combining all these capabilities, ports can be configured to perform complex operations. For example, the signal shown in Fig. 2 can be deserialised and clocked in by ports functions alone. Looking at the four data wires RX_D0..RX_D3 we can see bit patterns 0b0101, 0b1101, 0b0011, 0b0000, 0b1111, 0b1100, and a port can read these in as four bytes 0xD5, 0x03, 0xCF, or it can be programmed to ignore all data up to the 0xD nibble and just input the last two bytes.

../../_images/mii.svg

Example signals that XCORE ports can input.

You can use these advanced port operations to implement a wide range of interface protocols, and process signals without the need for core processor resources.

AN03007: XCORE Ports$$$System Design Using Ports and Libraries£££doc/rst/an03007.html#system-design-using-ports-and-libraries

XCORE ports can implement interface protocols in software. To make this easier for system designer, XMOS provides a set of software libraries that implement standard interfaces such as I2C, SPI, I2S, UART, etc. These libraries can be integrated into your design to implement these interfaces quickly.

You can instantiate one or more of the interfaces; during the instantiation you will set some of the fixed parameters of the interface, including the ports that should be used for this interface. You can then simply call the interface functions on this interface in order to perform high level operations.

You can find a full list of the available libraries on the XMOS library website. Each library links to a landing page with documentation, source code, and application notes using the library. As the libraries are normally distributed in source code form, you can take a library and modify the code in order to implement a special requirement.

AN03007: XCORE Ports$$$Example Applications Using Ports£££doc/rst/an03007.html#example-applications-using-ports

To illustrate the use of ports, we have several example applications that show how to use ports to implement a range of functions. These application notes are available from the XMOS application note website and you can use these as starting points for your own designs. All examples below show how to use ports - they deliberately do not instantiate libraries so that they can better illustrate the fundamental port features.

The classic example in embedded programming is to make an LED flash. This is the subject matter of AN02036: Making an LED glow using a simple PDM modulator which explores various ways to make a LED flash or glow with different brightnesses.

The Universal Asynchronous Receiver/Transmitter (UART) is a simple serial interface that is used to communicate with other devices. AN03000: XCORE Input and Output ends with a tutorial example showing how to implement a simple UART interface using the XCORE port I/O instructions.

The last section of AN03001: XCORE Clocked Input and Output contains an example of how to drive an LCD screen using the XCORE ports. This example illustrates the use of clocked ports to drive a high speed parallel interface to a screen,

Many other examples are available from the XMOS website that show how to use ports to implement a wide range of interfaces. These examples can be used as a starting point for your own designs and can be modified to suit your requirements.