Pin alternate functions (multiplexing)
All 32 I/Os work as general-purpose analog or digital pins. Fourteen of them can also be switched to a dedicated communication interface, and those interfaces share pins, so enabling one takes its pins away from the others. The table below is the single place that mapping is recorded: read down a column to see which GPIOs an interface consumes, or across a row to see what a given pin can become.
When a pin is used for a dedicated communication interface, it cannot be used as a general-purpose I/O, and more importantly, it cannot support the high voltage range of regular I/Os (-25 V to +25 V). Disabling the communication interface will restore the pin to its original I/O function and voltage range.
Before I2C, SPI, UART or PWM connects its pins, the device measures them. If a pin reads
below −0.5 V or above the interface's vcc + 0.5 V (4.6 V at most), enabling the
interface, or changing its vcc while it runs, fails with 409 UNSAFE_PIN_VOLTAGE and the
interface is left disabled. The error message gives the voltage measured and the allowed
window.
All alternate functions​
| GPIO | SPI | I2C | UART | PWM | JTAG * | SWD * | CAN | RS485 | RS232 |
|---|---|---|---|---|---|---|---|---|---|
| DA0-DA15 | |||||||||
| DA16 | MOSI_0 | SDA_0 | RX_0 | TDI_0 | SWDIO_0 | ||||
| DA17 | MISO_0 | PWM in | TDO_0 | ||||||
| DA18 | SCK_0 | SCL_0 | TX_0 | PWM out | TCK_0 | SWCLK_0 | |||
| DA19 | TMS_0 | ||||||||
| DA20 | MOSI_1 | SDA_1 | RX_1 | TDI_1 | SWDIO_1 | ||||
| DA21 | MISO_1 | PWM in | TDO_1 | ||||||
| DA22 | SCK_1 | SCL_1 | TX_1 | PWM out | TCK_1 | SWCLK_1 | |||
| DA23 | TMS_1 | ||||||||
| DA24 | CANH | A(+) 0 | |||||||
| DA25 | CANL | B(-) 0 | |||||||
| DA26 | A(+) 1 | ||||||||
| DA27 | B(-) 1 | ||||||||
| DA28 | TX | ||||||||
| DA29 | RX | ||||||||
| DA30-31 |
DA0 to DA15 and DA30 to DA31 have no alternate function and are always available as general-purpose I/O.
What this costs you​
Reading the table by interface:
| Interface | Pins it takes | Also blocks |
|---|---|---|
| SPI 0 | DA16, DA17, DA18 | I2C 0, UART 0, JTAG 0, SWD 0, PWM 0 |
| SPI 1 | DA20, DA21, DA22 | I2C 1, UART 1, JTAG 1, SWD 1, PWM 1 |
| I2C 0 | DA16, DA18 | SPI 0, UART 0, JTAG 0, SWD 0, PWM 0 |
| I2C 1 | DA20, DA22 | SPI 1, UART 1, JTAG 1, SWD 1, PWM 1 |
| UART 0 | DA16, DA18 | SPI 0, I2C 0, JTAG 0, SWD 0, PWM 0 |
| UART 1 | DA20, DA22 | SPI 1, I2C 1, JTAG 1, SWD 1, PWM 1 |
| PWM in 0 / PWM out 0 | DA17 / DA18 | SPI 0, I2C 0, UART 0, the other PWM pin of channel 0 |
| PWM in 1 / PWM out 1 | DA21 / DA22 | SPI 1, I2C 1, UART 1, the other PWM pin of channel 1 |
| CAN 0 | DA24, DA25 | RS485 0 |
| RS485 0 | DA24, DA25 | CAN 0 |
| RS485 1 | DA26, DA27 | - |
| RS232 | DA28, DA29 | - |
So SPI, I2C, UART and PWM on the same index are mutually exclusive, and CAN shares its pins with RS485 0. Everything else can run at the same time. RS232 has dedicated pins and never conflicts.
PWM takes a single pin but holds its whole channel, and the two PWM pins of a channel cannot be enabled together. See PWM measurement and generation.
JTAG and SWD are not currently supported and will be implemented in a future release. The AT1000 device is designed to support JTAG and SWD protocols, but the implementation is not yet available in the current version of the API. Please check back for updates on this feature.
An RS422 interface can be implemented by combining the two available RS485 interfaces. One pair (A(+) and B(-)) can be used for transmitting data, while the other pair (A(+) and B(-)) can be used for receiving data.
Rules the device enforces​
The device never takes a pin away from a GPIO configuration, or from another interface, on its own. It refuses the request instead, so a conflict shows up as soon as you run the script rather than as puzzling behaviour on the bench:
- Enabling an interface while another enabled interface uses its pins fails with
409 CONFIGURATION_CONFLICT, at the call that enables it (enable(), orconfigure()withenabled: true). - Enabling I2C, SPI, UART or PWM requires every pin it drives to be an analog input, the
default after
gpio.reset(). If one of them is configured as a digital input or output, an open drain or an analog output, the call fails with409 CONFIGURATION_CONFLICT(Cannot enable I2C_0 while IO 16 is configured as a GPIO) and the interface stays disabled. Reset the pin, or configure it as an analog input, first. - While I2C, SPI, UART or PWM is enabled, configuring one of its pins as a GPIO, or
resetting it, fails with
409 CONFIGURATION_CONFLICT(IO 16 is used by I2C_0). Disable the interface first.
SPI drives DA16 to DA18 (DA20 to DA22) only, so DA19 (DA23) stays available as a GPIO, for example as a chip select.