Arduino Uno R3 as a true ISP programmer for any AVR
Is there a driver that can be loaded in Arduino Uno R3 and turn this board into a pure ISP programmer for any AVR or at least for a few Attiny and Atmega which are used frequently?
I know, there is a tutorial, see:
that teaches people how to program stand alone ATmega168 or ATmega328 controllers, using Arduino Uno R3, but the operation is complicated involving two steps:
Writing a boot-loader to the stand alone AVR.
Removing the Atmega from Arduino Uno R3, changing the wiring required for (1) and finally writing the stand alone AVR with the desired hex file.
Is there a way to program a stand alone AVR in one step, by just connecting it to Arduino Uno R3, with the help of a few wires, without writing the boot-loader first?
It looks like this is possible, the only thing missing being the driver that transform Arduino Uno R3 into a real ISP programmer.
There is no reason you have to write the bootloader unless you want serial programming (FTDI/Atmega16u2 etc). You can hook up the SPI of the Arduino as ISP and connect the SPI pins of the target and upload away...
Your post seems to answer my question.
This is want I want to do, to program AVRs that have nothing to do with Arduino Uno R3 and the boot-loader on its Atmega328, and use them in various boards.
I will try to compile and upload, on my Arduino Uno R3 board, the sketch http://gammon.com.au/Arduino/Atmega_Board_Programmer.zip you indicated and follow the instructions on your site.
If I have supplemental questions I will come back.
Thank you
Yes, that will work fine. Any random hex file into any random avr is logically equivalent to burning the bootloader into an Arduino chip, except that you'll have to learn to use avrdude and fuses and such, instead of using the simple "burn bootloader" button in the arduino IDE.
I have tried to follow the steps from here ( http://arduino.cc/en/Tutorial/ArduinoToBreadboard ) to burn a bootloader in an identical controller (Atmega328p already configured for a 16 MHz crystal) as the one used by Arduino Uno R3, the board that I have.
First, I did not use avrdude but just Arduino 1.0.1. No bootloader can be loaded in the Atmega328p on the breadboard. I get the message "Invalide device signature".
Reading more carefully the instructions in the tutorial, I noticed that it says: "Note that these techniques only work with the Arduino Duemilanove w/ an ATmega328, not the Arduino Uno (or older Arduino boards w/ an ATmega168)."
which I guess means Arduino Uno R3 can simply not be configured by Arduino 1.0.1 as an ISP programmer and no bootloader can be uploaded in controllers on breadboards.
It is a bit puzzling but it looks like this is the reality.
If I use avrdude I get the same error message:
c:\>avrdude -P COM3 -b 19200 -c avrisp -p m328p -n
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.30s
avrdude: Device signature = 0x000000
avrdude: Yikes! [b]Invalid device signature.[/b]
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Same message I get if I try to use avrdude without connecting Arduino Uno R3 to the breadboard.
It looks like the connections between Arduino Uno R3 and the Atmega328p on the breadboard are not good but I checked them many times and they are ok.
simplex:
which I guess means Arduino Uno R3 can simply not be configured by Arduino 1.0.1 as an ISP programmer and no bootloader can be uploaded in controllers on breadboards.
No. Of course it can, and of course you can upload bootloaders.
You have a wiring issue or something like that. Post a clear photo please.
It seems that this is a oscillator related problem. The 16 MHz crystal is connected to the Atmega328p on the breadboard with a pair of 7 cm long wires. Could these wires act as capacitors at 16 MHz and replace somehow the two 22pF capacitors?
I think your Atmega is still running at 1 MHz (factory default). If you use Nick's programmer and the 8MHz signal from the D9 pin, you will crack that chip
I think the 8 MHz clock signal is described on this page:
I also think I altered the other sketches to output it (but maybe didn't describe it on the page).
I recently got an Atmega32U4 to program, and didn't have any luck until I slowed down the programming rate, and then it turned out it had the "divide by 8" fuse set.
It is clear that my chip on the breadboard is a 16MHz ATMega328p with bootloader preloaded.
I recently got an Atmega32U4 to program, and didn't have any luck until I slowed down the programming rate, and then it turned out it had the "divide by 8" fuse set.
Using this http://www.frank-zhao.com/fusecalc/fusecalc.php?chip=atmega328p
fuse calculator but in reverse, I get that my Atmega328p does not have the "divide by 8" fuse set and runs at 16 MHz.
This is the information I obtain if I introduce, in the line just above the black line of Frank Zhao's calculator, the values of fuses lfuse = FF, hfuse = D6, efuse = 5 which I read with avrdude from Atmega328p.
I wanted to make sure that my Atmega328p is set indeed for an external 16MHz crystal and not an internal oscillator.
In the meantime I read that breadbords do not work well above 10 MHz because of stray capacitors in the range of 2-20 pF that appear everywhere. The two 22 pF capacitors connected to the Crystal are in the order of magnitude of the stray capacitors so it looks like I had too much capacitance around the crystal, which was connected to the ground by the two 22 pF capacitors and to the uC by other, this time unwanted capacitors. Removing the two 22 pF capacitors somehow liberated the Crystal and made it to oscillate which it did not do before.
The 16 MHz crystal is connected to the Atmega328p on the breadboard with a pair of 7 cm long wires. Could these wires act as capacitors at 16 MHz and replace somehow the two 22pF capacitors?
Yeah, 7cm is pretty long for the connection to a crystal... On pretty much all of the real Arduinos I've used, the traces to the crystals are less than 1cm.
I'm with Nick in being confused. Where are you at this point? Are things working or not? Is the only issue remaining unexplained behavior that was solved by fiddling with the oscillator cap/wires/etc. And we're well beyond the thread title, right?
westfw:
I'm with Nick in being confused. Where are you at this point? Are things working or not?
Yes, my Atmega328p on the breadboard is working now. My post from "October 06, 2012, 01:20:29 PM" with the output generated by avrdude should have told you that, as long as I received the device signature and read the fuses.
simplex:
I wanted to make sure that my Atmega328p is set indeed for an external 16MHz crystal and not an internal oscillator.
The fuses tell you what it is set to. I don't understand what you are trying to do, except waste time.[/quote]
I am not familiar with avrdude. I launched it for the first time around 1 Oct. 2012.
A command like this: c:>avrdude -P COM3 -b 19200 -c avrisp -p m328p -n
outputs a lot of text out of which a large majority proved to be taken from a configuration file on the PC, not directly from the Atmega328p on the breadboard.
I did four tests:
Crystal connected with 22 pF capacitors both of them having one terminal grounded (the classical oscillator). avrdude output something.
Crystal with capacitors disconnected from the ground (removed from the circuit). avrdude output something different compared with what I had gotten at point (1).
Crystal removed from the circuit. avrdude displayed same thing as at point (1).
Arduino Uno R3 with ISP sketch loaded but not connected to the breadbord with Atmega328p. avrdude displayed same thing as per point (1).
So only point (2) was different, despite the fact the external resonator was in an unusual configuration, which told me that this might be the working case. Normally (1) should have been the only situation in which Atmega328p on the breadbord should have worked, not two.
I did not waste my time as long as I narrowed down the problem to the external oscillator.
Regarding the fuses, it is not self evident from the output of avrdude what is the frequency of the crystal connected to Atmega328p on the breadboard. I had to use an internet calculator, a thing that I finally did when I found out about the existence of such a tool, this is after my problem with the external oscillator had been already fixed.
Nothing you have said is anything to do with the Uno R3.
I use an Arduino Uno R3 as an ISP programmer. I confirm this 100%.