SAMD21 Mini/Dev Breakout Hookup Guide

Pages
Contributors: Jimb0
Favorited Favorite 3

Setting Up Arduino

While the SAMD21 alone is powerful enough, what truly makes it special is its growing support in the Arduino IDE. With just a couple click’s, copies, and pastes, you can add ARM Cortex-M0+-support to your Arduino IDE. This page will list every step required for getting SparkFun SAMD21 Breakout support into your Arduino IDE.

Update Arduino! This setup requires at least Arduino version 1.6.4 or later. We've tested it on 1.6.5 and the latest version – 1.6.6.

If you're running an older version of Arduino, consider visiting arduino.cc to get the latest, greatest release.

Install Arduino SAMD Boards

First, you’ll need to install a variety of tools, including low-level ARM Cortex libraries full of generic code, arm-gcc to compile your code, and bossa to upload over the bootloader. These tools come packaged along with Arduino’s SAMD board definitions for the Arduino Zero.

To install the Arduino SAMD board definitions, navigate to your board manager (Tools > Board > Boards Manager…), then find an entry for Arduino SAMD Boards (32-bits ARM Cortex-M0+). Select it, and install the latest version (recently updated to 1.6.5).

Installing the Arduino SAMD boards

Downloading and installing the tools may take a couple minutes – arm-gcc in particular will take the longest, it’s about 250MB unpacked.

Once installed, Arduino-blue “Installed” text should appear next to the SAMD boards list entry.

Install SparkFun Board Definition

Now that your ARM tools are installed, one last bit of setup is required to add support for the SparkFun SAMD boards. First, open your Arduino preferences (File > Preferences). Then find the Additional Board Manager URLs text box, and paste the below link in:

https://raw.githubusercontent.com/sparkfun/Arduino_Boards/master/IDE_Board_Manager/package_sparkfun_index.json

alt text

Then hit “OK”, and travel back to the Board Manager menu. You should (but probably won’t) be able to find a new entry for SparkFun SAMD Boards. If you don’t see it, close the board manager and open it again. ¯\(ツ)/¯.

Installing the SparkFun SAMD Boards

This installation should be much faster; you’ve already done the heavy lifting in the previous section.

Select the Board and Serial Port

Once the board is installed, you should see two new entries in your Tools > Board list: one for the Mini Breakout and one for the Dev. Select your SparkFun SAMD21 Board.

SparkFun SAMD21 Breakout board menu entry

Finally, select your SAMD21 Board’s port. Navigate back up to the Tool > Port menu. The port menu may magically know which of your ports (if you have more than one) are the SAMD21 board. On a Windows machine, the serial port should come in the form of “COM#”. On a Mac or Linux machine, the port will look like “/dev/cu.usbmodem####”.

Selecting the SAMD21 Board port

Select it!

Upload Blink

As with any development board, if you can blink an LED, you’re well on your way to controlling the rest of the world. Since the SAMD21 Boards have 3 user-controllable LEDs, let’s blink them all!

Mini Breakout with all LEDs on

The RX and TX LEDs are on pins 25 and 26, respectively, a couple pre-defined macros (PIN_LED_RXL and PIN_LED_TXL) can be used to access those pins, just in case you forget the numbers.

Here’s a quick example sketch to blink the LEDs and make sure your environment is properly set up. Copy and paste from below, and upload!

language:c
const int BLUE_LED = 13; // Blue "stat" LED on pin 13
const int RX_LED = PIN_LED_RXL; // RX LED on pin 25, we use the predefined PIN_LED_RXL to make sure
const int TX_LED = PIN_LED_TXL; // TX LED on pin 26, we use the predefined PIN_LED_TXL to make sure

bool ledState = LOW;

void setup() 
{
  pinMode(BLUE_LED, OUTPUT);
  pinMode(RX_LED, OUTPUT);
  pinMode(TX_LED, OUTPUT);
  digitalWrite(RX_LED, HIGH);
  digitalWrite(TX_LED, HIGH);
  digitalWrite(BLUE_LED, LOW);
}

void loop() 
{
  digitalWrite(RX_LED, LOW); // RX LED on
  delay(333);
  digitalWrite(RX_LED, HIGH); // RX LED off
  digitalWrite(TX_LED, LOW); // TX LED on
  delay(333);
  digitalWrite(TX_LED, HIGH); // TX LED off
  digitalWrite(BLUE_LED, HIGH); // Blue LED on
  delay(333);
  digitalWrite(BLUE_LED, LOW); // Blue LED off
}

After hitting the “Upload” button, wait a handful of seconds while the code compiles and sends. While the code uploads, you should see the yellow and green LEDs flicker.

Upload Troubles: If you see a No device found on cu.usbmodem#### error, try uploading once again and it should succeed.

mac upload fails

This issue has been most noticeable on Macs. After resetting the board into the bootloader, the delay before attempting an upload isn't long enough. After the first upload try, you should see the yellow "RX" LED illuminate – usually indicating the board has reset into bootloader mode. Another upload try should take.

Until solved, you may have to deal with either double-upload-clicking, or resetting the board into bootloader before uploading.

If your SAMD21 board still won't take your code, consult our Troubleshooting section.

Once you’ve verified that the IDE is all set up, you can start exploring the world of the ATSAMD21! Continue on for a few examples, which help show what makes the SAMD21 unique.