Teensy 3.5 serial console not active in setup()

Status
Not open for further replies.

aFewBits

Member
Arduino 1.8.9
OsX 10.11.6
Teensydunio 1.46 B10

I could not get messages in setup() to appear in the console. I reduced it down to this:

Code:
void setup() {
  Serial.begin(9600);
  Serial.println("Hello from Teensy");
}
void loop() {}

The message will not appear in the console until I do this:

Code:
void setup() {
  Serial.begin(9600);
  delay(2000);
  Serial.println("Hello from Teensy");
}
void loop() {}

Not sure of the time it takes for the console to connect but the 2 second delay definitely fixes the issue.

What am I missing?

Edit: not sure if this matters but the board is mounted on a Talldog DIP-64 Breakout. Powered by USB cable, VIN jumper on.
Edit: Not a breakout issue, just tried a virgin 3.6 board and it too has the same issue. Teensy clock rates don't matter either.
 
Last edited:
After .begin() add this:
Code:
  while(!Serial);
This gives the Serial device time to show up.

Pete
 
Thank you, that will get me moving off of full stop.

Was not aware it was required with Teensy and I never needed it prior to now. Will do some tests on older versions. (1.8.7 & 1.44)
 
Teensy has Native USB on the processor - so it disconnects during programming, unlike Arduino devices with a USB device off chip that stays connected during programming so the computer doesn't lose the connection.

Teensy hits setup() 300 milliseconds after powering up and getting the processor initialized. Then Serial can take another 30 or 200+ milliseconds to have the host usably connected - so getting started printing before Serial is online can lose stuff for some milliseconds without a wait. And if it Serial Monitor is not active until you connect it that adds the human time.

So the while(!Serial); will then wait forever until connected. If Serial is handy but not critical using something like : while(!Serial && millis() <2000); will in that case wait up to 2 seconds and then proceed - that is important to get right if the Teensy needs to run when a host doesn't connect - like a battery or other situation.
 
Status
Not open for further replies.
Back
Top