I want to learn AVR C programming instead of arduino programming. I have an arduino UNO board and few Atmega328 chips that I bought, and Atmel studio for programming. Can I use Arduino Uno board as programmer to flash the chips from Atmel Studio? Or any other alternatives?
-
Without a lot of knowledge on this subject, this post on the Arduino Forums and it looks related. For reference, what you want to do is use the Uno as an ISP.– Anonymous PenguinJul 31, 2014 at 0:25
-
Do your self a favor and buy a real programmer like the Atmel ICE, Dragon etc... You will thank me.– PhillyNJJul 9, 2015 at 1:58
4 Answers
If your chips have a bootloader already installed in them, you can use any USB -> Serial cable (FTDI cable) to program them in-circuit on their Rx/Tx pins. If not, you can use the Uno to program a boot loader into them (one time) and program them with the cable from then on.
To use standard C, you can use the bare chips or the UNO. You'll want a different environment than the Arduino IDE, though. That can be anything from an editor, the the gnu compiler tools run from a command line, to almost any other IDE. A number of people, myself included, use the Eclipse IDE with an AVR plug-in and do almost everything from writing the code to programming the AVR from within it. (I say 'almost' only because I personally prefer a full-blown programming editor, run outside of the IDE, for initial creation of sizeable projects or major edits and rewrites. That isn't necessary, though).
If you're starting out then Atmel Studio is a good option - it's very easy to install and get up and running, and I use it.
To use an Arduino as an ISP you're going to need to use AVRDude. You can configure Atmel Studio to flash chips using AVRDude - I struggled with this but eventually got it working, you can look here if it will help - not specifically for the Arduino as ISP, but should get you started.
Finally you should also double-check whether you have ATmega328-PU or ATmega328P-PU - AVRDude doesn't support the ATmega328-PU (without the P) so you'll need to do a workaround (again something that I've been caught out with in the past, [here's how I worked around it] (http://www.crash-bang.com/resource/bootload-atmega328/)
Good luck - programming the AVR directly is more challenging but gives you more control.
-
AVRDude does support the ATmega328 (no P) - however, the configuration file shipped when it is distributed by the Arduino folks may not include an entry for it. Jul 31, 2014 at 15:19
-
Essentially, it is to use menu Tools -> External Tools to define a new menu command that calls AVRDUDE with the appropriate parameters, using
$(TargetDir)
and$(TargetName)
to construct the full path to the hex file created by Atmel Studio. Oct 24, 2016 at 17:42
I want to learn AVR C programming instead of arduino programming.
It's not really clear what you think the difference is. You can use the Arduino IDE to do "straight AVR" programming, for example:
int main ()
{
DDRB = bit (5); // pin 13
DDRB |= bit (4); // pin 12
while (true)
{
PINB = bit (5); // pin 13
PINB = bit (4); // pin 12
}
}
The AVR register names (eg. DDRB, PINB, PORTB and so on) will be included by the IDE, however you don't have to use a single Arduino library or function if you don't want to.
-
Ah, cool you can actually "override" the main function and not use the setup & loop functions? But to be honest I would let everyone drop the arduino IDE. I think code-completion and/or code hints are very usefull for beginners.– PaulJul 8, 2015 at 7:40
-
Certainly, and you can specify an editor of your choice for the IDE. I just don't think that "Arduino programming", "C Programming" and the supplied IDE are different things. The IDE basically implements C++ so there is really no "Arduino language".– Nick Gammon ♦Jul 8, 2015 at 9:32
You can use the Atmel Studio + Visual Micro plugin to easily get started with atmega328 + support for the uno board (easily program, use arduino libraries etc). Checkout here. http://www.visualmicro.com/page/Arduino-for-Atmel-Studio.aspx
-
Just found in this forum that a similar answer exists for a similar question. arduino.stackexchange.com/questions/13225/… Jul 8, 2015 at 4:46