Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Serial connection question

  1. #1

    Serial connection question

    Hi all!
    I'm using Teensy v3.6 and on my setup I have something like this:

    // Wait Serial Monitor to open
    while (!Serial) ;

    I use this kind of Serial init on my Arduino board but on Teensy it seems that if I don't connect the serial monitor (Arduino IDE or Putty) the code stack on "while (!Serial) ;".
    Is that the correct behaviour? My problem is that my board won't startup if I just power it with no serial monitor opened.
    I just remove that line and everything seems work fine but I'd like to understand better.

    PS: I also can't see the setup Serial dump messages when I connect the board with Putty...

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    That is normal Teensy Behavior, !Serial is an absolute and it will never leave the while until connected.

    Teensy has TRUE USB hardware on the processor and until the Teensy starts up and gets to setup in about 300ms - the PC has not yet recognized the Teensy as a USB device until about 400 ms has passed.

    In the case of Arduino they may have an always on USB chip that the PC never loses connection with during program and restart - the Arduino starts more slowly - but it talks to USB over UART and that offers different behavior.

    Put something like this in setup() to wait - in this case 2 seconds - then continue without Serial.
    while ( !Serial && millis() < 2000 );

  3. #3
    ok thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts