Making the Move From the Arduino IDE to Atmel Studio

Moving from the Arduino IDE to a more advanced IDE such as Atmel Studio can allow you to greatly expand what your projects are capable of.

Evan Rust
5 years agoHW101 / Robotics / Productivity

Moving Up

Sometimes an Arduino board is not enough. They often hide much of the functionality of the microcontroller and the Arduino IDE does not provide ready access to the underlying modules. This can be frustrating, as some projects can't have the extra overhead given by a standard function, such as digitalWrite. This is where Atmel Studio comes into play. It is an IDE used by professionals that lets you write programs in C, C++, and even assembly for nearly all of Atmel's microcontrollers. Atmel Studio also lets you import Arduino sketches, but this should be avoided later on to avoid the continuation of bad habits. Since it is based on Visual Studio, anyone with who has used it should be able to quickly learn how to use Atmel Studio as well.

Installation

Atmel Studio 7 is the latest iteration of the IDE, and it is free to download and use for makers. Simply find it here and select the Web Installer. While installing, it's best to just select each architecture, as this prevents you from having to go back and download new MCU definitions later on.

Microcontroller Definitions and Hardware

In order to flash ICs, you can't just attach a USB cable to them and click upload. For one, several 8-bit MCUs don't have a UART interface, such as some of the ATtiny family. Second, the Arduino bootloader is what enables programming over the UART interface, but it takes up space, and space is precious. Rather, microcontrollers get flashed with programmers, and they send data via ICSP and some have debugging capabilities via JTAG or DebugWire. This method also frees up two pins for other uses. Below is the AVRISP mkii programmer (not debugger):

Programming Languages

As stated previously, Atmel Studio supports C, C++, and assembly for programming your microcontrollers. Assembly is normally used for getting extremely close to the hardware level, as it gives you access to all of the memory and registers. This is useful for creating programs that use very little RAM or making ultra-optimized programs. Normally, however, you'll use C, which is a wrapper around assembly. It restricts your access to the stack, but having variables, simple mathematical operators, and easy ways to use pointers is a major benefit. Higher level languages also handle the stack and argument passing for you, further simplifying the programming process.

A Very Different Paradigm

When using Arduino-style C++, you are used to having functions like digitalWrite, analogRead, delay, and Serial.print. Getting away from the Arduino IDE also forces you to lose those functions.

Initially, this can be upsetting and confusing, but it's all for the better. In order to create almost any program, you must configure and use the registers themselves, and this has an added benefit of forcing you to become familiar with the hardware at a low level. For example, you would normally use pinMode(pin, mode) to set whether a pin is an input or output on an ATtiny85. But using C or assembly, you would have to set a bit in the DDRB register and possibly set a bit in PORTB high for an internal pullup.

Using the Datasheet

The datasheet is your friend. It provides all of the necessary information about your microcontroller, including register definitions, electrical characteristics, and information about each module. For instance, section 10 of the ATtiny85 datasheet gives information about the I/O ports on the chip. Most sections have examples of how to configure registers, a register map that outlines the registers for a specific module, and descriptions for each bit in each register.

Although datasheets can seem overwhelming at first, by working through them and viewing examples, it will become very easy to implement even complex behavior.

Port and Register Macros

Using assembly requires reading from and writing to registers located in memory, but C makes this a bit easier. Rather than getting values directly, you can take advantage of macros, which get replaced with code that does this in the background. The IDE also comes with a file or files that associate a named register with its physical address in memory. This prevents you from having to memorize a long string of digits when trying to access a simple register or bit.

The Sky's the Limit

After making the switch from the Arduino IDE to Atmel Studio, you have nearly unlimited access to parts of the microcontroller, letting you have full control over the memory and each module. Atmel Studio also incorporates many other value features, such as a robust debugger, extensions, and much better source control.

Evan Rust
IoT, web, and embedded systems enthusiast. Contact me for product reviews or custom project requests.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles