# How to translate from data sheet to actual pin function (blank Atmel SAMD21)

I am looking for a way to actually read an Atmel processor (SAMD-21) pin setup; but I am not sure how do you actually get the right info from the data sheet.

I did read the pinout, which has names like PA00, PB03 and so on; reading in the multiplexed section, I see a table with each pin, but I can't get what it actually does. I was expecting something like "SPI MOSI" or "Serial TX" and such; instead the table has a ton of entry that does not look like anything that I recognize.

For example Pin 13 is PA08, as type it is mentioned as I2C, and the rest of the line has entry like

NMI  AIN[16]  X[0]  SERCOM0/Pad0  SERCOM2/Pad0  TCC0/WO[0]  TCC1/WO[2]  I2S/SD[1]


I did search in the section related to pinout, but there is only this table, which while it tell me if the pin is a I2C or SPI, it doesn't give me any context to translate in what I would see on a breakout board for example.

Is there a conversion table that show what these entry mean? I am a SW engineer, so this is my first attempt at reading a datasheet for a processor.

UPDATE:

Found some info online, after looking for SERCOM.

From my understanding, the SAMD21 has programmable pins, but there are some that are set as default for communication related to I2C, SPI and UART. These are under the name "SERCOM".

This show basically the default value for each pin, using an arduino zero board as reference

Pin     Default     SERCOM      SERCOM alt
-----------------------------------------
PA00    xtal                    SERCOM1.0
PA01    xtal                    SERCOM1.1
PB08                            SERCOM4.0
PB09                            SERCOM4.1
PA04                            SERCOM0.0
PA05                            SERCOM0.1
PA06                            SERCOM0.2
PA07                            SERCOM0.3
PA08                SERCOM0.0   SERCOM2.0
PA09                SERCOM0.1   SERCOM2.1
PA10                SERCOM0.2   SERCOM2.2
PA11                SERCOM0.3   SERCOM2.3
PB10    MOSI                    SERCOM4.2
PB11    SCK                     SERCOM4.3
PA12    MISO        SERCOM2.0   SERCOM4.0
PA13    EDBC        SERCOM2.1   SERCOM4.1
PA14                SERCOM2.2   SERCOM4.2
PA15                SERCOM2.3   SERCOM4.3
PA16                SERCOM1.0   SERCOM3.0
PA17                SERCOM1.1   SERCOM3.1
PA18                SERCOM1.2   SERCOM3.2
PA19                SERCOM1.3   SERCOM3.3
PA20                SERCOM5.2   SERCOM3.2
PA21                SERCOM5.3   SERCOM3.3
PA22    SDA         SERCOM3.0   SERCOM5.0
PA23    SCL         SERCOM3.1   SERCOM5.1
PA24    USB         SERCOM3.2   SERCOM5.2
PA25    USB         SERCOM3.3   SERCOM5.3
PB22    EDBG TX                 SERCOM5.2
PB23    EDBG RX                 SERCOM5.3
PA30    SWCLK                   SERCOM1.2
PA31    SWDIO                   SERCOM1.3
PB02                            SERCOM5.0
PB03    RX LED                  SERCOM5.1


So basically, you can set any of these pins if you need extra ports for I2C, SPI or UART.

Since I am using the bare SAMD21; I believe that the pins does not even have a default set. If anyone did start with a bare SAMD21, I would really appreciate some guidance about how did you set up the chip.

Pinout : page 26
Muxing table: page 33 to 36

• Please include a link to the datasheet in your question (and not in the comments) and reference the page / table number. – Transistor Jun 19 '16 at 7:51
• Thanks, I did add some extra info and the link as requested – rataplan Jun 19 '16 at 8:10
• See the PMUX registers and the PINCFGy registers. Sections 23.8.12 and 23.8.13 The PMUX registers apparently all default to function 'A'. See table 7.1 for the function associated with each pin; every pin has a default function although the pins are tristated at power-up. – Peter Smith Jun 19 '16 at 11:21

It is not unusual to see multifunction I/O pins on microcontrollers, so the tables in the datasheet (particularly table 7.1) identify the alternate functions associated with each pin (and by extension, the peripheral they can attach to internally).

This part is not much different from many variants using ARM Mx cores with multiple peripheral mappings.

The default pin function for all standard I/O pins is an ordinary digital I/O port (See the copied text from the datasheet at the bottom).

As an example, I will take a couple of lines from the table in question:

On the left is the physical pin (if it exists - depends on how many pins the package has and controller variant).

The next part is the port bit attached to the pin itself.

To the right of here is the supply pin(s) that actually power this I/O bit.

In the next column, we see I2C - this is explained in note 3:

1. Only some pins can be used in SERCOM I2C mode. See the Type column for using a SERCOM pin in I2C mode. Refer to Electrical Characteristics for details on the I2C pin characteristics.

This tells me that I can only use pins with I2C against them for the serial control unit(s) to be able to use an I2C interface.

To the right are alternate functions (if any exist) of A to H.

PB13 for example, has alternate functions in

A: EXTINT[13] which attaches to the interrupt controller if selected.

B -> X(11) for the touch controller

C -> SERCOM (serial module controller) number four which will attach to PAD1 as documented in the SERCOM chapter in the datasheet.

D, F and G have no alternate function.

E and F permit the pin to operate as part of the Timer / Counter module

Function G attaches the pin to the I2S (audio) module.

Function H attaches the pin as a generic clock (See the clock description in section 14 for details).

To use any function, you must (at least)

1. Turn on the clock associated with the function (or any writes to the peripheral are ignored - see the power manager module)

2. Enable the specific peripheral function

3. Programme the PMUX register(s) appropriately (see section 23.7).

4. Enable the multiplexed function in PINCFGy by setting the PMUXEN bit for the specific pin.

5. The other bits in PINCFGy must also be appropriately set.

Without knowing the specific setup you need, I cannot give further guidance.

Bit 0 – PMUXEN: Peripheral Multiplexer Enable This bit enables or disables the peripheral multiplexer selection set in the Peripheral Multiplexing register (PMUXn) to enable or disable alternative peripheral control over an I/O pin direction and output drive value. Writing a zero to this bit allows the PORT to control the pad direction via the Data Direction register (DIR) and output drive value via the Data Output Value register (OUT). The peripheral multiplexer value in PMUXn is ignored. Writing '1' to this bit enables the peripheral selection in PMUXn to control the pad. In this configuration, the physical pin state may still be read from the Data Input Value register (IN) if PINCFGy.INEN is set.

• Thank you so much! I see that the data sheet has basically all the info, but I wish I knew how to read them all. out of 1100 pages of that document, I was looking for something that would explain the usage in more simpler terms. Obviously you need to know how a basic microcontroller works to get the most out of a data sheet. I am using Atmel ICE as programmer, and Atmel studio as software. So far I have made a small breakout that expose the programming pins (swclk and swdio). Waiting for the ICE to be delivered, to give a try and see if I can put any code on the blank chip, maybe blink a led. – rataplan Jun 20 '16 at 6:15
• Do you know if there is any example that show how to deal with a blank chip? The examples from Atmel on the Atmel studio. are all related to their reference breakout board; I may be wrong but I assume that a blank chip is different from their reference board, since it has already the AVR on it, right? – rataplan Jun 20 '16 at 6:17
• A reference board will have the controller and a number of peripherals already placed. Are you using a commercially available board? I would expect the lowest level initialisation code to be the same whatever the target. – Peter Smith Jun 20 '16 at 7:00
• I am using a barebone chip; since I am making my own design, I do not have the option to use a reference board. So it should not matter if I do not use the reference board? Reading the documentation of the chip, it mention about the bootloader but I do not see examples of how you actually address the multiplexed pins to assign the correct functionalities. I could use the arduino sketch project template, since I have a breakout board with the SAMD21, which I did use with Arduino IDE. – rataplan Jun 20 '16 at 20:22
• I will take a look at this tonight to see if I can shed some light on it. – Peter Smith Jun 21 '16 at 13:18