[TUT][HARD] AVR programming with Arduino Uno as ISP

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since I've started my electronics hobby, I've had a few coder friends ask what kind of things one would need to start themselves. It's always been a pickle whether I should recommend something like Arduino, or going straight for a programmer and some AVR chips (which I personally like better but some might find the initial learning curve intimidating).

I had read about Arduino ISP sketch that enables using Arduino to program AVR chips. However, some said that the newer Uno boards are not supported, and some said the reset circuitry would need to be held up with a cap etc. So I decided to see myself if it could be done.

Turns out that the ArduinoISP sketch works just fine on my Uno R3 without any tweaks at all on Arduino 0022 IDE, but the 1.0 needed just a small code tweak (changing 1 number). After that I could use avrdude to program fuses and flash firmware with no problem at all.

I documented the process with clear pictures, and have also attached a PDF version of it just in case. I still recommend the web version due to easier reading a links:

http://codeandlife.com/2012/03/21/using-arduino-uno-as-isp/

With this tutorial, I can now happily recommend Arduino Uno for a beginner, knowing that even if their budget is tight (esp. students), the board doubles as ISP in case they ever grow out of it. :)

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A similar tutorial, about using Arduino Uno as an ISP programmer, can be found here:
http://pdp11.byethost12.com/AVR/...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First off, Thanks very much for your post here and on Code and Life, and for the link to the byethost12.com article.

I'm a newbie and don't even have an Arduino yet, but have now seen conflicting info on the use of the Uno to program blank (or w/bootloader) Atmega 328's. Info on THIS site suggests the Uno can be used. If true, then great!

I'm in the dark about the mentions of avrdude, though... Are we talking about software, or a stand alone programming device?

I would like to be able to program some AVR chips for dedicated use, but I don't want to buy a lot of extra gear, at least not right away...

Thanks in advance for your help, and thanks again for what you have already posted

Gonzo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrdude is a piece of software.

It knows and can drive almost every kind of AVR programming interfaces.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

very cool, jokkebk!
it's very good!

"One's value is inherent; money is not inherent"

 

Chuck, you are in my heart!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
avrdude is a piece of software.

It knows and can drive almost every kind of AVR programming interfaces.

Thanks for clarifying that, Clawson. I'm sure to have more questions for the forum...

My Arduino Uno is on its way to me, and should arrive today. I already received some spare Atmega328/w bootloader chips and a couple breadboards, waiting for 16Mhz crystals and other stuff in another shipment.

Can hardly wait to get my hands into the new hobby, and hope to make something useful.

Gonzo

***** UPDATE*****

Thanks to all of you for the great help & information! Following the instructions & wiring layout at

http://pdp11.byethost12.com/AVR/...

I got WinAVR from sourceforge.net

After I got over the fear of using Windows Command Prompt, I was able to use avrdude to load a sketch to an Atmega328p on a breadboard - using Arduino Uno as ISP. !!!

Baby steps, I know, but it sure feels like I won a battle!

Thanks again to all who contributed to this small victory...

Gonzo

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for this tutorial, but I have a little question.

Soryy I'm very noob on electronics and english(1 month arduino and upgrade to AVR 10 days ago, english is my 3rd language)'oops:

I want to receive Data back to my PC from my AVR(328p) for debug purpose (sensing data from Qtouch lib). I used to do with Arduino..

Is it possible when I use Arduino as Isp to have feedback on USB ?

do I have to it with SUART ? (I know that it is for coummunication between microcontrollers, I'm not there yet :?)

I know that there is dedicated kits for that but I'm learning and I don't want it to be easy.

PS: OUTOFTOPIC I've found this in the lcdLibrary by Peter Fleury :

#define DDR(x) (*(&x - 1))      //address of data direction register of port x 

I think it very useful but I didn't understand How it works, can anyone explain please or point me to a link. Thank you again

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The ArduinoISP sketch does NOT support a communications channel from the target after the programming is done.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I think it very useful but I didn't understand How it works, can anyone explain please or point me to a link.

This simply works on the fact that the ports in a tiny/mega always(?) have the registers laid out as:

  n: PINx
n+1: DDRx
n+2: PORTx

So if you want to know where DDRx is when given PORTx it is at N-1. Also you can access PINx as the PORT address - 2.

So if you have:

#define LCD_PORT PORTB

and you want to set some DDR bits relative to it you effectively want to use:

(LCD_PORT - 1) = value;

But you cannot simply do that in C. What you need is the "address of" LCD_PORT, that is &LCD_PORT. Then you need to subtract one from that, so (&LCD_PORT - 1) and then you need to turn that back into a pointer (*(&LCD_PORT - 1)).

And that's what the macro is doing. You use:

DDR(LCD_PORT) = value;

and it expands to be:

(*(&LCD_PORT - 1)) = value;

which in turn is something like:

(*(&PORTB - 1)) = value;

and lets say the address of PORTB is actually 0x38 so this becomes:

(*(0x38 - 1)) = value;

So this writes the value into location 0x37 which is the location of DDRB.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Crystal Clear.

Thank you very much of taking time to explain. This will make my life easier.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If someone is interested in Qtouch debugging.
According to this post, the only way to debug Qtouch Api are the QT600 and the TS2080x Protocols (property of Atmel) available only on this devices :
http://forum.atmel.com/archive/index.php/t-1959.html

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please stop making posts to this thread that are not relevant to the tutorial. Only post if you have further points to make about Arduino/ISP.

Moderator

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My First query was about debugging with Arduino ISP and in my case Qtouch debug. This was only an answer for all I found about the subject.