In this Section
↩ Return Home
↩ Return to Resources
See Table 6-1 in the SAMD datasheet linked above for all possible pin configurations on the SAMD51 microcontrollers.
Column 6 is the pad name that spans across all the different variations of SAMD51 microcontrollers. These are the pins you can specify using:
import microcontroller pinNum5 = microcontroller.pin.PB04
as opposed to the more-typical "PyCubed" name:
import board pinNum5 = board.AIN7
These are two ways to address the same pin. Reference that datasheet to see all the possible options.
Let's say we want UART hardware-enabled communication but have already used the default Tx and Rx pins on the board for something else.
Table 6-1 can seem daunting at first, so here's an example of how to read it.
Checking the datasheet (Table 34-1), we know UART pins need to have PAD,PAD,PAD listed in the 14th and/or 15th column in Table 6-1. The screenshot above shows two other pins that we should be able to use for UART. Pins #35 and #36 (PA16 and PA17) are on the payload breakout, but we should still be able to use them!
To demonstrate, we'll use a PyCubed board and connect to it over REPL:
Press any key to enter the REPL. Use CTRL-D to reload. Adafruit CircuitPython x.y.z; PyCubedv02 with samd51j19 >>> import board >>> import busio >>> uart = busio.UART(board.SDA2,board.SCL2) >>>
It works! 🎉 Weird, huh?
This is because there are multiple "nicknames" defined for these pins already. See Payloads & Interfacing with External Boards for more details on the connector.
Just as a cool side-example, you can easily see what pins are defined for the board object using the REPL:
>>> import board >>> dir(board) ['__class__', '__name__', 'AIN5', 'BATTERY', 'BURN1', 'BURN2', 'CHRG', 'DAC0', 'EN_GPS', 'EN_RF', 'I2C', 'L1PROG', 'MISO', 'MOSI', 'NEOPIXEL', 'PA16', 'PA17', 'PA19', 'PA20', 'PA22', 'PB16', 'PB17', 'PB22', 'PB23', 'RELAY_A', 'RF1_CS', 'RF1_IO0', 'RF1_IO4', 'RF1_RST', 'RF2_CS', 'RF2_IO0', 'RF2_IO4', 'RF2_RST', 'RX', 'RX2', 'SCK', 'SCL', 'SCL2', 'SDA', 'SDA2', 'SD_CS', 'SPI', 'TX', 'TX2', 'UART', 'VBUS_RST', 'WDT_WDI', 'board_id'] >>>
We can also use
microcontroller to get the exact same result and reduce confusion in our coding syntax. (note: reboot the board between experiments to reset the configurations)
>>> import microcontroller >>> import busio >>> uart = busio.UART(microcontroller.pin.PA16, microcontroller.pin.PA17) >>>
<aside> 💡 So to summarize:
You can call the same pin many different names from within CircuitPython because we've set up "nicknames" for them. But at the end of the day, what hardware-accelerated features the pins have are dictated by the datasheet.