Hi I am having trouble getting the DUE to output any serial information during the setup loop. I also want to understand better the 'soft erase' procedure.
In the arduino documentation (http://arduino.cc/en/Guide/ArduinoDue):
"Opening and closing the Native port at a baudrate other than 1200bps will not reset the SAM3X. To use the serial monitor, and see what your sketch does from the beginning, you'll need to add few lines of code inside the setup(). This will ensure the SAM3X will wait for the SerialUSB port to open before executing the sketch:
while (!Serial) ;"
I assume when I upload a sketch that the Arduino IDE handles the soft erase procedure in the background? Would this be a correct assumption?
Also I cannot get any output to print to serial monitor from the setup loop I have tried the following so far to no avail:
setup() {
while(!Serial); //Tried while(!SerialUSB); as well
SerialUSB.begin(9600); //Doesn't matter speed
SerialUSB.print("Hello World");
}
As well as:
setup() {
SerialUSB.begin(9600); //Doesn't matter speed
while(!Serial); //Tried while(!SerialUSB); as well
SerialUSB.print("Hello World");
}
Can anyone tell me how I can get my setup to properly print to serial monitor when I first load it up (the same way the old atmel atmega chips would print every time you opened serial monitor).
ageurtse:
Maybe a stupid question but did you hook up your usb kabel on the native usb port, not the programming port.
Indeed I have. I am having no trouble with SerialUSB.print and SerialUSB.write during the loop() {} phase of the program, but I do not get any output for the setup() {} phase of program.
Behavior on my arduino MEGA is that every time I open serial monitor the program reset from setup() {} and I see in serial monitor any print or write commands executed in setup. For the due this is not so, I never see the print and write commands that occur during setup(){}.
The native USB port does not trigger a reset on opening the serial monitor - if it did it would cause a USB disconnect. If you need auto-reset on opening the serial monitor, use the programming port.
stimmer:
The native USB port does not trigger a reset on opening the serial monitor - if it did it would cause a USB disconnect. If you need auto-reset on opening the serial monitor, use the programming port.
Makes sense. But what is this all about? It can be found in arduino documentation.
"Opening and closing the Native port at a baudrate other than 1200bps will not reset the SAM3X. To use the serial monitor, and see what your sketch does from the beginning, you'll need to add few lines of code inside the setup(). This will ensure the SAM3X will wait for the SerialUSB port to open before executing the sketch:
while (!Serial) ;"
stimmer:
The native USB port does not trigger a reset on opening the serial monitor - if it did it would cause a USB disconnect. If you need auto-reset on opening the serial monitor, use the programming port.
Makes sense. But what is this all about? It can be found in arduino documentation.
"Opening and closing the Native port at a baudrate other than 1200bps will not reset the SAM3X. To use the serial monitor, and see what your sketch does from the beginning, you'll need to add few lines of code inside the setup(). This will ensure the SAM3X will wait for the SerialUSB port to open before executing the sketch:
while (!Serial) ;"
Ordinarily that line would be very funny. However, they've overloaded the boolean operator for that class so, in theory, it will return true only if the USB port is active and somebody is listening. So, that line really should be waiting until you connect a terminal program to the serial port. I don't know why that isn't working for you. Perhaps it might be a good idea to make the program wait for you to press a key before it actually progresses. This could be as simple as: