AVR V.S. Arduino

I recently ran into an AVR STK500 for $1.25 so i had to buy it. My question is, can an an AVR alone run Arduino code?

yes it can. Get an atmega168 or 328 and it is very easy. Simply burn the bootloader to the chip...

you can also try other controllers, but for a start I would get an atmega168 or 328, because they are used by the official Arduino boards.

You can burn the bootloader to the chip by connecting ISP6PIN to the right SPROG pin header and then use the IDE to burn the bootloader.

For the stk500v2 it is a good idea to add the following lines to the programmers.txt:

avrstk500v2.name=AVR stk500 v2

You have to select the right serial port in the menu before you can burn the bootloader.

Then use the "RS 232 SPARE" of the stk500 and connect the corresponding pins on the other side of the board to the right pins of the mega168 (rx and tx). Then you can upload sketches to the mega via this com port.

Oh and use an external crystal... 16MHz. The stk500 can hold it in the CRYSTAL slot. Then you must adjust the jumper for the crystal, not sure what it is called... look it up in the user manual. Otherwise the mega can't run at 16MHz and then serial communication won't work (and thus no sketches can be uploaded)

What does installing a bootloader do? why cant i just flash my code directly to it? If i dont install the arduino bootloader can i still run arduino code on it?

the bootloader receives the program code from the serial port. If you don't use a bootloader then you can burn the program using an isp programmer... but I recommend to use the bootloader. The upload button of the Arduino IDE sends the program code to the bootloader, so this makes everything a lot easier.

ooh, i was just confused because this http://www.ethernut.de/en/documents/led-blink.html looks MUCH diff from this http://www.arduino.cc/en/Tutorial/BlinkingLED Why are they so different if arduino is just a bootlaoder?

Arduino is not just a bootloader.

If you want to create a board that behaves like the original Arduino HARDWARE then you must install the bootloader.

The Arduino SOFTWARE is divided into two parts: the IDE that you use and the libraries that allow you to use (parts of) the so called wiring language... so the Arduino has its own programming language (an extension to C or C++) if you want to put it that way.

So to get started: burn the bootloader to the chip and then play with the Arduino IDE and the examples that come with it. It is really easy.

See also this recent article on using a STK500 as an Arduino:


good article. Shows the wires, jumpers and the crystal that I mentioned.

But again, I would burn the bootloader with the Arduino IDE. It is easier than the AVR Studio solution proposed in the article and runs on Windows, Mac OS and Linux.

I already own an arduino, as well as the stk500. I already learned some basic arduino coding. I guess the root of my question is: What are the real differences between using arduinos IDE for arduino bootloaded chips and Atmel's AVR Studio for stock ATMEL chips? Is the code backwards compatible?

The best way to find that out is to download AVR Studio and WinAVR and try to develop an application.

Developing in C in AVR Studio is not that far removed from the Arduino environment. The main difference is that you're not coddled with wrappers for the hardware, you get in there and poke bits into registers with one eye on the 400+page datasheet. There are rewards...you can develop for any AVR chip, there's a simulator and in-system debugger. But it's overall a much more intense development cycle that has few safety nets.

Developing in assembly in AVR Studio is about as far as you can get from the Arduino environments padded corners, but the potential for minimal, fast code is there. But it's entirely possible for someone with little knowledge of assembly to write code worse than the C compiler.