Hello all, I am seeking help with programming an arduino MEGA via the ICSP using a USBasp. I have gone through the required firmware dates to the USPasp and such. I am even able to upload code to the arduino UNO using this method with no problems via the arduino IDE or microsoft visual studio. However, when I attempt to upload to the MEGA boards nothing happens. I get no errors. The compiler says everything was successful but I cannot get the simple blink code to work. Below is the message I recieve when attempting to upload to the MEGA. I get the same type of message when i upload to the UNO but in that case it actually works.
Compiling 'test' for 'Arduino Mega 2560 or Mega ADK'
Binary sketch size: 1632 bytes (of a 258048 byte maximum) (0.2140123 secs)
Uploading to I/O board using 'usbasp'
Done uploading
Here is the simple code I am uploading
int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second
}
I have tried using the USBasp, Arduino UNO, and Arduino Mega as a programmer to write to a mega with no success. Any clue what I am missing?? Still not getting any error messages, just a non responsive board.
Any suggestions why this method works for programming the arduino UNO but not the Mega??
Do you see an "SS" (SPI CHIP SELECT) on the ICSP connector for the mega ?
Do you have pin 53 connected to the SS PIN on the USBasp ?
Can ANY SPI interface work WITHOUT a chip select ?
I can't find any pinout documentation for your USBasp board. All I can find is the connector pinout which doesn't have an SS pin.
I can't help you with your USBasp but for what it is worth, I bought two TINYISP s from kickstarter and discovered that there was no connection from pin-1 of the ATtiny85 on the ATtinyISP to the 6 pin ICSP header, and as you may or may not know, this is the wire connections from an UNO to program an ATtiny85.
Pin connections:
ATtiny Pin 2 to Arduino Pin 13 (or SCK of another programmer)
ATtiny Pin 1 to Arduino Pin 12 (or MISO of another programmer)
ATtiny Pin 0 to Arduino Pin 11 (or MOSI of another programmer)
ATtiny Reset Pin to Arduino Pin 10 (SS) (or RESET of another programmer)
Attached is the wiring illustration that shows the SS pin of the UNO is actually connected to the RESET pin of the ATtiny85 but
it is also PCINT5. In the ArduinoISP sketch the pin is called SLAVE RESET.
I really don't know why it is necessary but if I don't connect a jumper wire from my UNO pin -10 (SS) to the attiny85 -pin-1
(RESET), I cannot program the chip, including the BURN BOOTLOADER option I need to put a bootloader in the chip.
Your mega already has a bootloader so you don't need that option.
Look at this code in ArduinoISP sketch
#include "pins_arduino.h"
#define RESET SS
void start_pmode() {
spi_init();
// following delays may not work on all targets...
pinMode(RESET, OUTPUT);
digitalWrite(RESET, HIGH);
pinMode(SCK, OUTPUT);
digitalWrite(SCK, LOW);
delay(50);
digitalWrite(RESET, LOW);
delay(50);
pinMode(MISO, INPUT);
pinMode(MOSI, OUTPUT);
spi_transaction(0xAC, 0x53, 0x00, 0x00);
pmode = 1;
}
I don't know anything about the USBasp but I know that even though it is only used ONCE with a 50ms delay in the INIT routine it is apparently important because it will not init the SPI without it. You can ask Crossroads what to do but you may need to find a way to connect to the pin on the USBasp that performs a similar (SS) function. I have no clue about that other than what I just told you.
Thanks for your help. The issue is not unique to the USBasp. As I mentioned I get the same results using the Arduino UNO and MEGA as an ISP. Also, I am able to burn the bootloader with no problems. It is just when I attempt to upload software (blink) that I get nothing. I get no errors, which seems to mean that the software uploaded just fine. However, the LED does not blink.
I asume the programmer is working because you can
upload the bootloader. Then is everything ok.
The problem is on the Mega2560 board you
want to programm. Change to following fuses:
Low: FF High: D8 EXT: FD Loc: FF and erase the chip.
Don't forget to disconnect or power down.
Plug in and start Arduino IDE and try again
to upload a sketch eg. blink.
aerouta:
Thanks for your help. The issue is not unique to the USBasp. As I mentioned I get the same results using the Arduino UNO and MEGA as an ISP. Also, I am able to burn the bootloader with no problems. It is just when I attempt to upload software (blink) that I get nothing. I get no errors, which seems to mean that the software uploaded just fine. However, the LED does not blink.
Burning a boot loader is a 2 step process outside the Arduino GUI.
burn flash with bootloader
burn the fuses
If you then use ISP to load the sketch, you overwrite the boot loader.
Nick has some excellent diagnostic sketches and instructions here:
A bootloader is for when programming via the USB.
And ofcourse the fusebits are set in that way the
programm you upload don't overwrite it and
start at the right adress. Therefor you have
buyed an Arduino board.
For programming via ISP you don't need a bootloader.
So get rid of that thing. Not everyone has an Arduino
but using only a bare Atmel. I am happy that I now
can programm my 2560 in my project via ISP.
pe1mxp:
A bootloader is for when programming via the USB.
And ofcourse the fusebits are set in that way the
programm you upload don't overwrite it and
start at the right adress. Therefor you have
buyed an Arduino board.
For programming via ISP you don't need a bootloader.
So get rid of that thing. Not everyone has an Arduino
but using only a bare Atmel. I am happy that I now
can programm my 2560 in my project via ISP.
Is there some point to this post?
Or, are you just stating the obvious.
When commenting, it is best to think, articulate, and proofread.