Go Down

Topic: No Prints printed in Void Setup when using SerialUSB (Read 1 time) previous topic - next topic


Hi :),

I am using the SerialUSB of the Due and i have a print statement in the Void Setup of the code. But this does not get printed unlike the normal Serial. Is there something I'm doing wrong?

Code: [Select]

void setup(){

  /* Uninitialize if not needed */
  SerialUSB.println("Initializing, Please wait...");


Did you select Arduino DUE (Native USB Port) in Tool>Type of board ?

After:  SerielUSB.begin(250000); // The baud rate is irrelevent for SerialUSB  but must be different from 0
write: while (!Serial); // Wait for the 480 MHz clock to be ready


Yes. I selected the Native Port to view printed data. Print statements in the Void loop execute fine, but print statements in the Void setup don't seem to print.


In Tools>Port: select Port"Comx(Arduino DUE(Native USB Port))"


Another possibility is that it is sending but you aren't able to receive it. What I mean is, on the Due the SerialUSB is natively hosted on the CPU itself. It is initialized upon start up and enumerated at the PC side. But, this happens very quickly. If you are currently connected to the Due then the USB must be dropped, the CPU reset, and the USB reconfigured every time you upload a sketch or reset the CPU. You do not have time to power cycle the device, get the com port opened, and read the message before the message has been sent. It just happens too quickly and you miss the message while trying to connect to the COM port. The solution is to delay a bit at the start of the setup function to give time for the PC to connect and be read to receive. This can all be annoying. On other boards the USB is set up outside the chip (say, by a different chip) and that other chip doesn't reset with the main CPU so the USB connection stays up. That way when you reboot the main CPU the USB is still connected and you can get messages right away. But, the Due is different because one chip hosts both the USB connection and the main program.

Hopefully that adequately explains it. This is one of the most annoying things about the Due. It has many other good qualities but hosting USB on the same chip as you are running the rest of your sketch has a big downside.

Go Up