CrossPack is a development environment for Atmel’s AVR® microcontrollers running on Apple’s Mac OS X, similar to AVR Studio on Windows. It consists of the GNU compiler suite, a C library for the AVR, the AVRDUDE uploader and several other useful tools.
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.
Also the Atmel Software Framework of chip-specific source code libraries is available as a huge zip file download independent of Atmel studio. GDB works well with an SWD adapter for Atmel's ARM parts, there are some indications it can be made to work with the AVRs connected via an Atmel ICE, but never personally tried that. Share this:Atmel Studio 6 – The Integrated Development Environment Atmel® Studio 6 is the integrated dev. Download avr studio 5 Share this:AVR Studio 5: Avr Studio is an Offical released IDE (Integrated development environment) for Atmel. The new Atmel Studio 7 IDE can be installed in parallel with an existing Studio 6.2 installation, as long as the two versions are not installed in the same directory. However, we strongly suggest upgrading existing installations to this new release, as it contains numerous enhancements and bug fixes made since the last release of Atmel Studio. Downloads Archive for AVR and SAM MCUs/MPUs. Atmel Studio 7 IDE Archives. Web Installer (recommended). You'll need an integration with the Atmel Studio platform. The Atmel Studio Extension Developer's Kit (XDK) can assist you with the integration. MAC OS X 64-bit Linux 64-bit Release Notes/Readme: ARM GNU Toolchain 5.3.1.
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)
Click CREATE NEW PROJECT
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.
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.
VERY CRITICAL BIT!
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) {
delay_ms(500);
gpio_toggle_pin_level(LED1);
}
delay_ms(500);
gpio_toggle_pin_level(LED1);
}
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.
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:UsersrobDocumentsAtmel Studio7.0MrBlinkyMrBlinkyDebugMrBlinky.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.
Atmel Studio Mac Download Mac
You should see dozens of lines out stuff, with no error messages. And the red light on you Feather should be blinking away.
Download Atmel Studio 6.2
Should be simple enough to add the bossac command to Atmel Studio so that the upload can be done from inside the IDE.
Atmel Studio 6.2 Download Mac
Rob