Digital i/o: Basics

General-purpose input/output (GPIO) describes a connection that, as the name implies, can be used for input or output and whose functionality depends on the peripheral. On the MSP432, these GPIO (also referred to as digital I/O for the MSP432) connections come in the form of pins. Pins, like on an IC, are physical structures that can create connections between the microcontroller and a peripheral. Pins essentially act as wires, and as such, each pin can only carry one bit of data at a time.

A pin can be configured either as an input or an output, but not both at the same time as it will create possibility for a short if two opposing values are driven to it. In order for the pin to "remember" if it is configured as an input or an output, a memory element such as flip-flop is needed, which is called a register in this context. In addition to the direction of the pin, there are various configurations that control how the I/O pin behaves. All these configurations are preserved in various registers.

A group of pins is called a port. Since pins can be configured in various ways, each port has its own set of registers. Each bit of those registers corresponds to a pin. So if we had three ports (numbered from 0 to 2), each with 8-bit registers, then each port has eight pins. For every register in Port 0, Bit 0 corresponds to Pin 0. Similarly, for every register in Port 0, Bit 1 corresponds to Pin 1. However, these Pins 0 and 1 are not the same Pins 0 and 1 for Port 1, nor are they same Pins 0 and 1 for Port 2. In this example, each individual port has their own set of eight pins (numbered 0 to 7). Each pin in a specific port shares that port’s registers, but not the registers of other ports, even if the pins have the same number.

Because pins can be configured as inputs or outputs, there exists quite a bit of circuitry between the pin and its port’s registers. Each pin is connected to its own individual set of multiplexers and tri-state buffers (among other components). As such, each digital I/O pin belonging to the same port can have different configurations from one another. For instance, Pins 0 and 2 of Port 1 can be configured as inputs while Pins 1 and 3 of the same Port 1 can be configured as outputs.