Hello,
So I have a Arudino due based board which I am trying to flash. I select Arduino Due (Native USB port) and then COM3 which is the port I am connecting the board to. As soon as I upload this appears:
Write 35040 bytes to flash (137 pages)
[ ] 0% (0/137 pages)
[== ] 9% (13/137 pages)
[===== ] 18% (26/137 pages)
[======== ] 28% (39/137 pages)
[=========== ] 37% (52/137 pages)
[============== ] 47% (65/137 pages)
[================= ] 56% (78/137 pages)
[=================== ] 66% (91/137 pages)
[====================== ] 75% (104/137 pages)
[========================= ] 85% (117/137 pages)
[============================ ] 94% (130/137 pages)
[==============================] 100% (137/137 pages)
done in 1.510 seconds
Verify 35040 bytes of flash
[ ] 0% (0/137 pages)
[== ] 9% (13/137 pages)
[===== ] 18% (26/137 pages)
[======== ] 28% (39/137 pages)
[=========== ] 37% (52/137 pages)
[============== ] 47% (65/137 pages)
[================= ] 56% (78/137 pages)
[=================== ] 66% (91/137 pages)
[====================== ] 75% (104/137 pages)
[========================= ] 85% (117/137 pages)
[============================ ] 94% (130/137 pages)
[==============================] 100% (137/137 pages)
Verify successful
done in 1.037 seconds
Set boot flash true
CPU reset.
But immediately after the port COM3 disappears from the Tools menu and I can't open the serial monitor which I would like to use to see some values. The board is not recognized anymore, I have to press erase and then reset button to make it appear again but I basically can't debug.
Is this behavior normal? Any solution?
Thanks
The native USB port is sensitive to electrical issues it "sees" (The UOTGHS is clocked at 480 MHz). I guess you may have a defective USB cable or connection, although the upload seems OK, try to use a new one.
Each time the USB 2.0 protocol detects an electrical issue, it tries to swap to another port.
Note that the port itself should appear as native usb port in your IDE window.
Since your code is properly uploaded, you just need to push the reset pin several times (and not the erase pin) and a new COM port will appear. You can now open your serial monitor (and run your code).
Thanks,
So I am trying a very basic code
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
Serial.println("begin");
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = 4;
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}
The code is uploaded fine: now I see even after I upload my code that the port is still selected COM12 (Arduino USB native port). But when I open the serial monitor nothing is displayed. I try to hit reset multiple times AFTER the uploading but still nothing is shown in the terminal. Any clue?
Obviously, you need to print with SerialUSB.print() with the native USB port !!
And BTW, when using SerialUSB, it's better to add while(!SerialUSB); after SerialUSB.begin(9600); because of the 480 MHz clock.
Thanks I solved that problem. Now the problem I am facing is different. Using a simple sketch as the one I posted everything is fine and I dont lose connectivity to the port. If I try to upload a much more complicated program (CAN communication between two boards and reading some sensors) then after I successfully upload the code, I lose the connectivity (I dont see the Arduino due USB native port anymore on the tools menu. Is this due to a software/code reason or can still be something in the hardware?
I don't know this issue (native USB lost connectivity in conjonction with CAN bus enable).
If you use the programming port instead of the USB port, do you have the same issue ?
At the beginning of your code, add:
#define SerialUSB Serial
Then comment or uncomment this line whether you want to use the USB port or not.
So using the Arduino Due (Programming port) I got this error
Atmel SMART device 0x285e0a60 found
SAM-BA operation failed
An error occurred while uploading the sketch.
So I guess I have to use the Native port. What is annoying is that with the simple sketch everything is fine, using a this more complex project, I loose the connectivity. I removed the serial.print and SerialUSB.print but the problem persists. So observing the different behavior with two different programs uploaded, I guess the error is in the code somewhere but it sounds strange.
You need to select Arduino DUE Programming Port before uploading via the Programming Port !!
I tried to use the programming port but I keep getting this error
Atmel SMART device 0x285e0a60 found
SAM-BA operation failed
An error occurred while uploading the sketch
At least with native USB port I can upload the program AnalogReadSerial. Insteas, my complex project uploads but then loose the connectivity with the port and I can't work on it.