Go Down

Topic: Unable to upload programs to an Arduino Mega2560 (!!! Bug) (Read 718 times) previous topic - next topic

ANewbie

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:
.
.
.

Coding Badly


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

ANewbie

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: [Select]
Serial.println("Read back.............");

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

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

Coding Badly

#3
Aug 12, 2011, 03:53 am Last Edit: Aug 12, 2011, 03:55 am by Coding Badly Reason: 1
Quote
[font=Courier New]Serial.println("No record found!!!!");  // <--- These exclamation marks are the problem.[/font]


ANewbie

#4
Aug 12, 2011, 03:56 am Last Edit: Aug 12, 2011, 04:20 am by ANewbie Reason: 1
 :smiley-red:


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

Best regards,
ANewbie

Coding Badly


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.

ANewbie

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.

;)

Go Up