Adafruit Feather M0 with Atmel Studio

Atmel Start

This is a quick ‘Hello World’ post which shows how to use Atmel Start to create an Atmel Studio project which is compatible with the ARM based  Adafruit Feather M0. It will toggle the Feather’s LED at 500ms intervals.

The motivation is to move away from the Arduino IDE and libraries (I’ve been struggling with I2C misreads and slow serial speed) and instead use Atmel’s excellent and free Atmel Studio. It can be daunting for Arduino users to make the jump but it’s absolute bliss having a professional IDE.

Atmel recently launched an online tool which allows you to create and configure a template solution for a given set of hardware. It has examples projects for a huge range of developer boards (e.g the Xplained Pro series). It also allows you to create your own custom hardware and “graphically” configure clocks,  pin mappings (PINMUX) and also add software ‘drivers’ for things like I2C and USB.

So start with Atmel Start :


Click Create new Project

On the right hand side in the ‘filter on text’ field enter the name of the chip that the Feather M0 uses:  ATSAMD21G18 and then select the QFN48 package (I don’t believe it makes a difference in this case which package you choose as the pin-outs are the same)



You will get a fairly empty looking stack of components. Here’s I’ve just renamed the Application to something more appropriate.


Next, select PINMUX and scroll down and select to  Pin 26 ( PA17). Or you can select it from the graphical image of the chip itself. How cool is that!

Change the Label to LED1 and Pin Mode to Digital Output.

NOTE Atmel Start is SMART. It will only let you select pin modes that are compatible with the chip and pin, e.g. you can select I2C mode for PA22/PA23 but not PA24.


Next click on CLOCKS.  We won’t change any of the defaults. This will run MrBlinky at 1Mhz. But as you can see you have access to the whole world of SAMD21 clocks. You can also add components which depend on clocks.


Back to the dashboard we will add something that will enable us to include a delay in our code, essential for MrBlinkey to blink. There are a huge number of ‘driver’ components to choose from and you can add as many as you need (space allowing). Here we just add a delay component. Click on the (+) next to DRIVERS, scroll down to Dela,  click on the (+)  on the far right to add to the list of new components and finally click Add Component(s).



Now lets get the project into Atmel Studio. Click EXPORT PROJECT , ensure Atmel Studio is ticked and click DOWNLOAD PACK.


In The Studio

Run Atmel Studio and select File->Import->Atmel Start Project

Navigate to where the project pack was downloaded and select it. Update the project & solution name to something sensible.


Select  Build -> Rebuild and there should be no errors or warnings.


While this builds a nice binary file in the project “Output Files” folder and indeed you can flash this to the Feather M0 (instructions coming up below) IT WONT WORK. Why ? Because REASONS:


So we need to tell the linker to link our code to execute at address 2000 rather than 0.

In the Solution Explorer right click on the Project (MrBlinky) and select Properties. Select the Toolchain option on the left hand side and navigate down to the ARM/GNU Linker / Miscellaneous section.

In the Linker Flags field add :    -Wl,–section-start=.text=0x2000


close up:


Blinking LED

open up Main.c and you will see a while loop. Add some code to blink the LED

while (true) {

Note that the delay_ms function is there because we added Delay as a component and LED1 has also been defined for us because we labelled PA17 earlier. This is very handy if you’re designing custom hardware with specific things hanging off of specific pins, such as Chip Enables, leds, PWM outputs, I2C buses…

Rebuild Mr Blinkey.

Flash, ah–ahhhhhh!

To upload the executable to the Feather M0 we can use the build-in Arduino Bootloader.

The Arduino IDE uses a utility called bossac to push the exe up to the target board. You can see what command the Arduino IDE runs by turning on “Show Verbose Output During Upload”  Preferences.  Create a dummy sketch, select the Adafrtui Feather M0 and the bootloader port (double tap the button on the Feather to put it into bootloader mode) and then compile/upload the sketch.

The command line for me is basically :

<path to Arduino tools>/bossac.exe -i -d –port=<COM Port> -U true -i -e -w -v “C:\Users\rob\Documents\Atmel Studio\7.0\MrBlinky\MrBlinky\Debug\MrBlinky.bin” -R

The location of bossac.exe will vary as will the com port that the Feather is on so change accordingly. The location of MyBlinky.bin will also vary (check Output Files under Solution Explorer in Atmel Studio).

Double tap the Feather reset button to put it in bootloader mode. Open up a command prompt and run the above bossac command.

You should see dozens of lines out stuff, with no error messages. And the red light on you Feather should be blinking away.

Should be simple enough to add the bossac command  to Atmel Studio so that the upload can be done from inside the IDE.










Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s