Skip to main content

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.

I/O voltage range

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​

GPIOSPII2CUARTPWMJTAG *SWD *CANRS485RS232
DA0-DA15
DA16MOSI_0SDA_0RX_0TDI_0SWDIO_0
DA17MISO_0PWM inTDO_0
DA18SCK_0SCL_0TX_0PWM outTCK_0SWCLK_0
DA19TMS_0
DA20MOSI_1SDA_1RX_1TDI_1SWDIO_1
DA21MISO_1PWM inTDO_1
DA22SCK_1SCL_1TX_1PWM outTCK_1SWCLK_1
DA23TMS_1
DA24CANHA(+) 0
DA25CANLB(-) 0
DA26A(+) 1
DA27B(-) 1
DA28TX
DA29RX
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:

InterfacePins it takesAlso blocks
SPI 0DA16, DA17, DA18I2C 0, UART 0, JTAG 0, SWD 0, PWM 0
SPI 1DA20, DA21, DA22I2C 1, UART 1, JTAG 1, SWD 1, PWM 1
I2C 0DA16, DA18SPI 0, UART 0, JTAG 0, SWD 0, PWM 0
I2C 1DA20, DA22SPI 1, UART 1, JTAG 1, SWD 1, PWM 1
UART 0DA16, DA18SPI 0, I2C 0, JTAG 0, SWD 0, PWM 0
UART 1DA20, DA22SPI 1, I2C 1, JTAG 1, SWD 1, PWM 1
PWM in 0 / PWM out 0DA17 / DA18SPI 0, I2C 0, UART 0, the other PWM pin of channel 0
PWM in 1 / PWM out 1DA21 / DA22SPI 1, I2C 1, UART 1, the other PWM pin of channel 1
CAN 0DA24, DA25RS485 0
RS485 0DA24, DA25CAN 0
RS485 1DA26, DA27-
RS232DA28, 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: Not currently supported

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.

NOTE about RS422

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(), or configure() with enabled: 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 with 409 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.