I recently uploaded this sketch on my Arduino MEGA 2560
uint32_t j = 0;
uint16_t n = 0;
uint32_t i = 0;
const uint16_t t1_load = 0;
const uint16_t t1_comp = 890;
void setup() {
// Serial.begin(2000000);
DDRG |= (1 << PG5);
DDRB |= (1 << PB7);
DDRH |= (1 << PH6);
DDRB |= (1 << PB4);
DDRE |= (1 << PE4);
DDRE |= (1 << PE3);
PORTG &= ~(1 << PG5);
PORTH &= ~(1 << PH6);
PORTE &= ~(1 << PE4);
PORTB &= ~(1 << PB7);
PORTB &= ~(1 << PB4);
PORTE &= ~(1 << PE3);
cli();// stop interrupts
TCCR1A = 0; //reset the value
TCCR1B = 0; //reset the value
TCNT1 = 0; //reset the value
OCR1A = t1_comp; // compare match value
TCCR1B = 0b00001001; //WGM12 bit is 1 and no prescaler
TIMSK1 |= (1 << OCIE1A);
sei();// enable interrupts
}// put your setup code here, to run once:
void loop() {
// put your main code here, to run repeatedly:
}
ISR(TIMER1_COMPA_vect) {
uint8_t T;
if (n == 0) {
for (i = 0; i < 63000 ; i = i + 1) {
PORTG &= ~(1 << PG5);
PORTH &= ~(1 << PH6);
PORTE &= ~(1 << PE4);
PORTB ^= (1 << PB7);
PORTB ^= (1 << PB4);
PORTE ^= (1 << PE3);
//delay(1);
delayMicroseconds(80);
}
for (i = 0; i < 63000 ; i = i + 1) {
PORTG &= ~(1 << PG5);
PORTH &= ~(1 << PH6);
PORTE &= ~(1 << PE4);
PORTB ^= (1 << PB7);
PORTB ^= (1 << PB4);
PORTE ^= (1 << PE3);
//delay(1);
delayMicroseconds(80);
}
for (i = 0; i < 63000 ; i = i + 1) {
PORTG &= ~(1 << PG5);
PORTH &= ~(1 << PH6);
PORTE &= ~(1 << PE4);
PORTB |= (1 << PB7);
PORTB |= (1 << PB4);
PORTE |= (1 << PE3);
//delay(1);
delayMicroseconds(80);
}
for (i = 0; i < 63000 ; i = i + 1) {
PORTG &= ~(1 << PG5);
PORTH &= ~(1 << PH6);
PORTE &= ~(1 << PE4);
PORTB |= (1 << PB7);
PORTB |= (1 << PB4);
PORTE |= (1 << PE3);
//delay(1);
delayMicroseconds(50);
}
n = n + 1;
}
}
After that, I tried to upload another code and I got this error message
Sketch uses 1490 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
An error occurred while uploading the sketch
I googled the solutions of the problem but non seem to work.
I tried uploading a blink sketch,
I tried the trivial reset and wait for a couple minutes
none works
I tried to bootload with Arduino UNO and also I tried to override, I got this..
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
Error while burning bootloader.
I tried to change the device signature in avrdude.config but I cannot save any changes.
File > Preferences > Show verbose output during: > compilation (uncheck) > upload (check) > OK
Tools > Burn Bootloader
After the process fails you'll see a button on the right side of the orange bar "Copy error messages". Click that button.
Paste the error messages in a reply here USING CODE TAGS (</> button on the forum toolbar).
Please provide a description of the connections you made between the Uno and the Mega.
JAJSentina:
I tried to change the device signature in avrdude.config but I cannot save any changes.
Don't change the signature. That will only cause problems once you get things working correctly and it's extremely unlikely that will help with your problem anyway.
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cstk500v1 -PCOM3 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM3
Using Programmer : stk500v1
Overriding Baud Rate : 19200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x03
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x03
avrdude done. Thank you.
Error while burning bootloader.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I tried the capacitor across the gnd and reset.
If I use an electrolytic capacitor, whats the polarity. Should I connect the reset pin to the positive polarity?
After bootloading using a ceramic cap. I got this error.
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cstk500v1 -PCOM3 -b19200 -e -Ulock:w:0x3F:m -Uefuse:w:0xFD:m -Uhfuse:w:0xD8:m -Ulfuse:w:0xFF:m
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM3
Using Programmer : stk500v1
Overriding Baud Rate : 19200
AVR Part : ATmega2560
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PA0
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 10 8 0 no 4096 8 0 9000 9000 0x00 0x00
flash 65 10 256 0 yes 262144 256 1024 4500 4500 0x00 0x00
lfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
efuse 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
lock 0 0 0 0 no 1 0 0 9000 9000 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : STK500
Description : Atmel STK500 Version 1.x firmware
Hardware Version: 2
Firmware Version: 1.18
Topcard : Unknown
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x000000 (retrying)
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x000000 (retrying)
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x000000
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
avrdude done. Thank you.
Error while burning bootloader.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I see that the verbose error output changed. I cant really understand this, but I assumed adding the capacitor changed the error message
JAJSentina:
Should I connect the reset pin to the positive polarity?
Correct.
JAJSentina:
After bootloading using a ceramic cap. I got this error.
I think this is actually progress. My interpretation is that the original error you were getting was caused by the Arduino as ISP board being reset when the Burn Bootloader process started. Now, I believe the Arduino as ISP is working correctly but it's not getting any communication with the Mega's microcontroller.
As to why it's not getting any communication. It may be a wiring problem. The connections you listed are fine, but sometimes jumper wires have internal breaks that cause them not to conduct. Please check your wire continuity and double check all your connections.
It could also be that the ATmega2560 on the Mega has died. Hopefully not.
After checking the connections of the wire, I found that one jumper wire was defective. I did the same procedure again and I finally was able to bootload my MEGA. However, another problem occured. I uploaded a blink sketch in my MEGA ang I was got this error
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
Sketch uses 1462 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM1 -b115200 -D -Uflash:w:C:\Users\ZIBERJ~1.YSU\AppData\Local\Temp\arduino_build_262951/Blink.ino.hex:i
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM1
Using Programmer : wiring
Overriding Baud Rate : 115200
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude done. Thank you.
An error occurred while uploading the sketch
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I thought bootloading would solve the problem but I still got an error