Read this first

I will not duplicate what has already been described elsewhere; basic information can be found here: Arduino Zero Overview
See HERE for a detailed description about the SAMD21.

NEW: Mini SAMD21 development board 15x15mm (Arduino compatible)

The smallest Arduino compatible SAMD21 board: 15x15 mm, 34 I/O pins
The smallest Arduino compatible SAMD21 board: 15x15 mm, 34 I/O pins

The SAM 15x15 is an Arduino development board of just 15 x 15mm, with the same powerful controller as the Arduino Zero: the SAMD21G18. Despite the small size, it has more I/O pins than the Arduino Zero: 34 instead of 20. See the article and how to buy here.

Official Arduino boards with the SAMD21G

Arduino Zero

Contains the Embedded Debug hardware (EDBG)

Arduino Zero
Arduino Zero

Arduino M0 Pro

This board is very similar to the Arduino Zero. Note that, by mistake, the digital pins 2 and 4 are swapped.

Arduino M0 Pro
Arduino M0 Pro

Arduino M0

This board is sold on eBay. Note that it has no EDBG like the M0 Pro.

Arduino M0 without EDBG
Arduino M0 without EDBG

SAMD21 mini breakout

It has no EDBG and can be programmed by the native USB port.

SAMD21 Mini Breakout
SAMD21 Mini Breakout

Attention: maximum 3.3V

The Arduino Zero works at 3.3V instead of 5V. The SAMD21G will be blown up when connecting voltages higher than 3.3V to the pins. This risk is reduced if the external electronics also has a supply voltage of just 3.3V.
The 5V pin on the connector also creates a risk of accidental connecting it to a SAMD21G pin. I have therefore sealed the 5V pin so that this never can happen.
Some pins are also connected to the EDBG chip, this is very risky: the EDBG chip can be blown up also. This chip can't be replaced; you have to buy a whole new Arduino Zero board.

Programming ports

The Arduino Zero has two different USB programming ports:

Native USB port

This is connected directly to the SAMD21.
This is the simplest solution and works without EDBG, it is used on the SAMD21 mini breakout.
Note: Use SerialUSB instead of Serial for communication with the PC.

Programming port

This is used with the EDBG, see below:

What is the purpose of the EDBG?

The Atmel Embedded Debugger (EDBG) is formed by a ball grid array IC. It was not immediately clear to me what its purpose is, because you can simply program the SAMD21 without any additional hardware via the native USB port and the Arduino software.

In summary, the EDBG is required for:

Dead bootloader fix

If the native port doesn't work anymore, you can fix this with double-tapping the reset button. See the article HERE.

Arduino Zero debug connectors

The Arduino Zero board has 3 kinds of debug connectors, which is rather confusing especially since there are also several names used. Here is a summary:

JTAG connector

JTAG is a standardized test system for PCBs.
It is connected to the EDBG chip.

SWD connector

Also called Cortex debug connector. See the Atmel story of the Serial Wire Debug (SWD) port HERE
This is a 2-pin Serial Wire Debug (SWD) port; it is an alternative to JTAG.
This is connected directly to the SAMD21.

ICSP connector

In-Circuit Serial Programming (ICSP) also called In System Programming (ISP) or Serial Peripheral Interface Bus (SPI)
This is connected directly to the SAMD21 and uses the connections MISO, MOSI, SCK and RESET.
It is also used for short distance communication between ICs.
Note: the Arduino Zero is not an AVR type Atmel controller, and thus, it can't be programmed by ISP.

Important things to know about the SAMD21

  • On the SAMD21, an int stores a 32-bit (4-byte) value. This yields a range of -2,147,483,648 to 2,147,483,647 (-2^31 to 2^31 - 1).
  • ATSAMD21G18A-AUT typenumber explanation: G = 48-pin version, 18 = flash memory density 256kbyte / SRAM 32 kbyte. For the ATmega328P this is respectively 32kbyte and 2 kbyte.
  • 32768kHz crystal
    A built-in phase-locked loop (PLL) creates the internal 48MHz clock frequency out of the 32768kHz crystal.
  • VDDCORE pin
    Take care of the VDDCORE pin 43: this is an internal regulated voltage of 1.2V for the processor core. Don't connect it accidentally with 3.3V! It needs a decoupling capacitor of 1μF.
  • 12-bit PWM DAC
    For the 12-bit PWM DACs use the code extension analogWriteResolution(12).

How to use the 10 bit analog DAC

A0 is a 12 bit analog input but also a 10 bit DAC output. 

analogWrite(A0, 512); // set to 1.65V

How to use the analog pins as digital input/output

In fact, the SAMD21, like the ATmega328, has no special analog pins: all pins are general purpose I/O-pins whereby some pins can be used as analog input. Here is an example for A0:

pinMode(A0, OUTPUT);
digitalWrite(A0, b); // A0 as digital out 

The analog connector A0...A5 is very confusing; in addition, there are also other pins at the Arduino Zero with an analog inputs.
Note that A0 is just another name for 14, so A0=14, A1=15 ... A5=19.

digitalWrite(A0, 0) is equal to digitalWrite(14, 0)

How to use the PWM DAC

Almost all pins can also be used as a PWM DAC (pulse-width modulation). The function analogWriteResolution() sets the resolution, default is just 8 bits (0...255). The Arduino Zero PWM frequency is 730Hz for all PWM pins 3, 4, 5, 6, 8, 9, 10, 11, 12, 13. Pins 2 and 7 have no PWM at the Arduino Zero.

analogWrite(3, 2048); // set to 1.65V

Note that there is a bug: analogWrite has to be disabled if the pin gets another I/O function:


void setup() 
{ analogWrite(2, 127);
  pinMode(2, INPUT); // turn off PWM
  pinMode(2, OUTPUT); // now we can use the pin for digital I/O
  digitalWrite(2, 0);
void loop()

FlashStorage library


Cristian Maglie has built a library for the non-volatile flash memory of the SAMD21, see HERE

IBDAP debug adapter for the SAMD21

IBDAP debug adapter for the SAMD21
IBDAP debug adapter for the SAMD21

Instead of the EDBG, which is used by the Arduino Zero, the SAMD21 can also be debugged with IBDAP. It is a fully CMSIS-DAP compatible debug adapter. It provides vendor independent debug interface for ARM 32-bit Cortex microcontrollers over JTAG/SWD interface. You can do debugging functions like stepping, breakpoints, watch points and firmware download etc. See the website HERE.

Do you have any comments? Please let me know.
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.