This issue is if you externally power your Teensy and cut the trace for the usb power.
Compile (USB Serial) and upload the sketch below, open the Arduino Serial Monitor (leave it open) and disconnect the USB cable you will notice that the Teensy keeps blinking when it should stop because of the "while(!Serial);" part of the code. If you just open and close the Serial Monitor with a valid USB cable connected the blinking will stop as expected.
When disconnecting the USB cable the SLEEP status bit gets set for the USB isr to handle. I think this is the where CDC_SET_CONTROL_LINE_STATE needs to be reinitialized to its default values.
Compile (USB Serial) and upload the sketch below, open the Arduino Serial Monitor (leave it open) and disconnect the USB cable you will notice that the Teensy keeps blinking when it should stop because of the "while(!Serial);" part of the code. If you just open and close the Serial Monitor with a valid USB cable connected the blinking will stop as expected.
When disconnecting the USB cable the SLEEP status bit gets set for the USB isr to handle. I think this is the where CDC_SET_CONTROL_LINE_STATE needs to be reinitialized to its default values.
Code:
const int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
while(!Serial);
Serial.println("HI");
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW);
delay(100);
}