Pages: [1]   Go Down
Author Topic: Unable to upload programs to an Arduino Mega2560 (!!! Bug)  (Read 670 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am newbie to Arduino.... I bought a Mega2560 and a Duemilanove before. Then I tried to make a batteries tester with Arduino. But sometimes I can not upload to Mega2560, but Duemilanove can, with same sketch!!! It will halt up when uploading to Mega2560. I have to un-plug the USB cable and plug again. The 8u2 version is 0001 already.
Following is part of sketch, it has upload problem if I don't comment out the red section.....

Does anyone can give some tips?

Thanks,
ANewbie


void loop() {
  switch(mode) {
    //---------------------
    case STANDBY:
      //read button press
      if(readPress) {
        readPress = 0;
        Serial.println("Read back.............");
//-------------------------------------------------------------------------------------!!!
//          if(testCount == 0) {
//           Serial.println("No record found!!!!");
//          }
//-------------------------------------------------------------------------------------!!!

          for(int i = 0; i < testCount; i++) {
            Serial.print(i);
            Serial.print("  ");
            for(int j = 0; j < numberOfBattery; j++) {
             Serial.print(result[i * numberOfBattery + j]);
             Serial.print(" V  ");
            } //for
            Serial.println();
          } //for
        isRead = 0;
      } //if
      //Start button means start testing.........
      if((startPress == 1) && (isRead == 0)) {
        mode = TESTING;
        startPress = 0;
        sec10 = 0;
        seconds = 0;
      } else {
        startPress = 0;
      }
    break;
    //----------------------
    case INITIAL:
.
.
.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12929
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


The three exclamation marks in a row are the problem.  The 2560 bootloader incorrectly interprets them as a command to enter "monitor mode".
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your reply.
But the "three exclamation marks" are added on this forum only for easy reading, not in IDE. In IDE, I just use "//" to comment out. And the problem is it will fail to upload to 2560 if I take out the "//" likes following. It is not my first time, I tried before then I am making a new code, but still happened.

Best regards,
ANewbie

Code:
Serial.println("Read back.............");

          if(testCount == 0) {
           Serial.println("No record found!!!!");
          }

          for(int i = 0; i < testCount; i++) {
.
.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12929
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Serial.println("No record found!!!!");  // <--- These exclamation marks are the problem.
« Last Edit: August 11, 2011, 08:55:29 pm by Coding Badly » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  smiley-red


Thank you! I will try it!
(update) I tried it and it works!, Thanks a lot.

Best regards,
ANewbie
« Last Edit: August 11, 2011, 09:20:59 pm by ANewbie » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 208
Posts: 12929
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Thank you for the follow-up.  I'm glad you have it working.

Just so you know, with your Duemilanove you could replace the bootloader on your Mega2560 with a version that does not have this bug.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for your information. However, I think I will not touch bootloader at this moment. And I will keep in mind about the bug.

 smiley-wink
Logged

Pages: [1]   Go Up
Jump to: