7

I see that on the official Arduino website, the reference page contains the functions and vales you would use specified to the Arduino compiler.

http://arduino.cc/en/Reference/HomePage

What would you use instead, if you are working with Atmel Studio?

Chetan Bhargava
  • 4,612
  • 5
  • 27
  • 40
Aleatory
  • 497
  • 2
  • 5
  • 12

2 Answers2

7

The language is the same. You can either use Arduino IDE or Atmel Studio (http://www.engblaze.com/tutorial-using-atmel-studio-6-with-arduino-projects/) The Arduino libary is more of a wrapper to make it easy to do things, like digitalWrite, which you do not have by default in Atmel Studio (or you can define it yourself). With Atmel Studio you would flip a bit in a register to turn on the digital port. Now for the AtMega2560 and the AtMega328 these registers are different. So you can't just compile the same source and expect it to run on both MCU's when using the registers. Again, of course, you can specify a compiler flag that you are now using AtMega2560 or AtMega328 and define the registers in your own digitalWrite function accordingly, and that is exactly what the Arduino library is doing for you.

You can choose to use the Arduino Library while working in Atmel Studio, or you can choose to use native register operations toggling bits and so forth using Arduino IDE. To get Atmel Studio running with Arduino library and AVR dude requires some setup, but it might be worth it, depending on how large your code project is. Atmel Studio is based on Microsofts Visual Studio with code suggestion/completion and intellisense which could drastically speed up the development of the code.

Mike de Klerk
  • 541
  • 1
  • 4
  • 14
  • Manipulating timer 0 while using the Arduino library is a bad idea though. – Ignacio Vazquez-Abrams Oct 07 '13 at 04:49
  • Tutorial: Using Atmel Studio 6 with Arduino projects: http://www.engblaze.com/tutorial-using-atmel-studio-6-with-arduino-projects/ also relevant: http://forum.arduino.cc/index.php/topic,123267.0.html – Connor Wolf Oct 07 '13 at 05:15
2

Something that's available when using Atmel Studio is the Atmel Software Framework that gives some hardware abstraction like the Arduino libraries. It allows the same code (within reason) to run across multiple Atmel platforms including the AVR and their ARM based products. I've only just started using it for a new project but here's an example of some code:

#define RADIO_RX IOPORT_CREATE_PIN(PORTA, 0)
ioport_set_pin_dir(RADIO_RX, IOPORT_DIR_INPUT);
data_in = ioport_get_pin_level(RADIO_RX);

It appears to have very good support for on-chip peripherals such as USB, SPI, USART etc. across their range. It also has some support for external peripherals such as an SD card with a FAT software stack and some LCDs although in that regard it seems limited pretty much to the devices they use on their development boards.

While the language is the same one thing that might add to the learning curve is you'll probably find less example code and high-level libraries using ASF, for instance that interface to a particular RF transceiver or GPS receiver.

Often though those sorts of libraries that attempt to hide the hardware layer too much can lead to unexpected problems when you don't know the underlying operation and how things will work together. From that point of view I think ASF gives a good level of abstraction to make things easier to read and port between Atmel devices while still giving good control over the hardware.

PeterJ
  • 17,131
  • 37
  • 56
  • 91