Arduino Forum

Products => Arduino Due => Topic started by: sfr7 on Apr 06, 2019, 01:16 pm

Title: Uploading problem
Post by: sfr7 on Apr 06, 2019, 01:16 pm
Hi, I am trying to test my arduino due with basic code examples but when uploading them to my board I recieve this message:



El Sketch usa 11116 bytes (2%) del espacio de almacenamiento de programa. El máximo es 524288 bytes.
Atmel SMART device 0x285e0a60 found
Erase flash
done in 0.031 seconds

Write 12304 bytes to flash (49 pages)

[                              ] 0% (0/49 pages)
[==                            ] 8% (4/49 pages)
[====                          ] 16% (8/49 pages)
[=======                       ] 24% (12/49 pages)
[=========                     ] 32% (16/49 pages)
[============                  ] 40% (20/49 pages)
[==============                ] 48% (24/49 pages)
[=================             ] 57% (28/49 pages)
[===================           ] 65% (32/49 pages)
[======================        ] 73% (36/49 pages)
[========================      ] 81% (40/49 pages)
[==========================    ] 89% (44/49 pages)
[============================= ] 97% (48/49 pages)
[==============================] 100% (49/49 pages)
done in 2.401 seconds

Verify 12304 bytes of flash

[                              ] 0% (0/49 pages)
[==                            ] 8% (4/49 pages)
[====                          ] 16% (8/49 pages)
[=======                       ] 24% (12/49 pages)
[=========                     ] 32% (16/49 pages)
[============                  ] 40% (20/49 pages)
[==============                ] 48% (24/49 pages)
[=================             ] 57% (28/49 pages)
[===================           ] 65% (32/49 pages)
[======================        ] 73% (36/49 pages)
[========================      ] 81% (40/49 pages)
[==========================    ] 89% (44/49 pages)
[============================= ] 97% (48/49 pages)
[==============================] 100% (49/49 pages)
Verify successful
done in 2.209 seconds
Set boot flash true
CPU reset. 
Title: Re: Uploading problem
Post by: pert on Apr 06, 2019, 01:22 pm
Congratulations! That means the upload was successful. Carry on.
Title: Re: Uploading problem
Post by: sfr7 on Apr 06, 2019, 02:02 pm
Thank you very much for your response, the problem is that I am trying to impement the code below, and I cannot visualize the values in the serial monitor.



void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}


Title: Re: Uploading problem
Post by: ard_newbie on Apr 06, 2019, 02:27 pm

1/Check you have selected the same baud rate in your sketch (here 9600) as in Serial Monitor (Would be much better to select 250000).

2/analogRead() will give you a positive 12-bit number, therefore sensorValue should be an uint16_t, not an int.

3/ Select A0 as an input pin : pinMode(A0, input); in setup()
Title: Re: Uploading problem
Post by: sfr7 on Apr 06, 2019, 03:13 pm
Thank you ard_newbie but it still doesn't work. I've checked the board, the port, updated the libraries, reseted the board but it returns the same message and the serial monitor doesn't give a feedback of the sensor response.
Title: Re: Uploading problem
Post by: ard_newbie on Apr 06, 2019, 03:49 pm

In  Tools>Board Select Arduino Programming Port
In Tools>Port, select the correct COM Port (e.g. COM9 Arduino DUE(Programming Port))

Push the Reset button after uploading,even though  this is usually not neccesary to run the sketch.

Your code runs when the Serial Monitor is open with the correct baud rate. Without anything connected to A0, you should read the noise (~ 500)
Title: Re: Uploading problem
Post by: pert on Apr 07, 2019, 02:09 am
There are two USB jacks on the Due:
(https://www.arduino.cc/en/uploads/Main/DueUSBPorts.jpg)
Your code is written for use with the Due connected to the computer via the Programming Port.

https://www.arduino.cc/reference/en/language/functions/communication/serial/ (https://www.arduino.cc/reference/en/language/functions/communication/serial/)
Title: Re: Uploading problem
Post by: sfr7 on Apr 07, 2019, 04:00 pm
Thank you for your answer, but I've checked that and the serial monitor still doesn't work
Title: Re: Uploading problem
Post by: pert on Apr 07, 2019, 05:00 pm
What happens if you run this simple sketch?:
Code: [Select]
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("hello");
  delay(1000);
}

Make sure the baud rate menu at the bottom right corner of the Serial Monitor is set to 9600.
Title: Re: Uploading problem
Post by: sfr7 on Apr 07, 2019, 05:09 pm
The serial monitor is empty and it returns this information:


El Sketch usa 22212 bytes (4%) del espacio de almacenamiento de programa. El máximo es 524288 bytes.
Atmel SMART device 0x285e0a60 found
Erase flash
done in 0.033 seconds

Write 24480 bytes to flash (96 pages)

[                              ] 0% (0/96 pages)
[==                            ] 9% (9/96 pages)
[=====                         ] 18% (18/96 pages)
[========                      ] 28% (27/96 pages)
[===========                   ] 37% (36/96 pages)
[==============                ] 46% (45/96 pages)
[================              ] 56% (54/96 pages)
[===================           ] 65% (63/96 pages)
[======================        ] 75% (72/96 pages)
[=========================     ] 84% (81/96 pages)
[============================  ] 93% (90/96 pages)
[==============================] 100% (96/96 pages)
done in 4.716 seconds

Verify 24480 bytes of flash

[                              ] 0% (0/96 pages)
[==                            ] 9% (9/96 pages)
[=====                         ] 18% (18/96 pages)
[========                      ] 28% (27/96 pages)
[===========                   ] 37% (36/96 pages)
[==============                ] 46% (45/96 pages)
[================              ] 56% (54/96 pages)
[===================           ] 65% (63/96 pages)
[======================        ] 75% (72/96 pages)
[=========================     ] 84% (81/96 pages)
[============================  ] 93% (90/96 pages)
[==============================] 100% (96/96 pages)
Verify successful
done in 4.327 seconds
Set boot flash true
CPU reset.
Title: Re: Uploading problem
Post by: ard_newbie on Apr 07, 2019, 05:39 pm

Try this out:

At the beginning of your sketch, add this line #define Serial SerialUSB

Connect your board to the Native USB Port,
In Tools>Board select Arduino (Native USB Port)
In Tools > Port select COMx (Arduino Native USB Port) --> unplug/plug the USB cable until you see the correct COM port
Build your sketch and upload.



Once upload is completed, open serial Monitor. What's going on this time on Serial Monitor ?
Title: Re: Uploading problem
Post by: sfr7 on Apr 07, 2019, 06:30 pm
My computer doesn't recognise the native usb port, only the programming port.