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

Thread: Teensy 3.0 doesn't restart on serial monitor

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Location
    Toledo, Ohio
    Posts
    10

    Teensy 3.0 doesn't restart on serial monitor

    I was trying to debug some code running on a Teensy 3.0 and was getting some really odd results. After a lot of going back and forth, I figured it out. When you open the serial monitor in the Arduino IDE, it doesn't restart the Teensy 3.0 as it does for ATmega boards including the Teensy 2.0. For example, see this sketch:

    Code:
    int cnt = 1;
    
    void setup() {
      Serial.begin(115200);
      pinMode(LED_BUILTIN, OUTPUT);
      digitalWrite(LED_BUILTIN, LOW);
      delay(100);
      digitalWrite(LED_BUILTIN, HIGH);
    }
    
    void loop() {
      Serial.println(cnt++);
      delay(1000);
    }
    On an ATmega board (including Teensy 2.0), every time you open the serial monitor window in the Arduino IDE, the LED blinks and it starts the counting at 1, then 2, etc. But, run the same sketch on the Teensy 3.0 and you'll get something totally different. The LED doesn't blink and the counter will display how many seconds since you uploaded the program or the last time you hit the reset button. For example, 5 then 6, etc. If you close the serial monitor, wait 10 seconds and open the serial monitor again, the LED won't blink and the display will read something like 17, 18, etc.

    Try this, with the above sketch on a Teensy 3.0, try to get the serial monitor to start with 1, near impossible (best I could do was 2). Because of this, all sketches where you want to get a serial output you need to start the sketch with a several second delay, hit the reset button on the Teensy 3.0, then open the serial monitor.

    Am I missing something or doesn't the Teensy 3.0 have the ability to trigger a restart via the serial monitor?

    Tim

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,112
    I would say that not restarting every time you open a serial monitor is a feature, not a bug. If you want it to restart, press the restart button.

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,112
    Quote Originally Posted by teckel View Post
    Because of this, all sketches where you want to get a serial output you need to start the sketch with a several second delay, hit the reset button on the Teensy 3.0, then open the serial monitor.
    This is the benefit of the Arduino ERW environment (a lightly modified Arduuino release with some bug fixes and improvements). One of the the features it gives is 'upload then open serial monitor'.

  4. #4
    Junior Member
    Join Date
    Nov 2012
    Location
    Toledo, Ohio
    Posts
    10
    Quote Originally Posted by Nantonos View Post
    I would say that not restarting every time you open a serial monitor is a feature, not a bug. If you want it to restart, press the restart button.
    Not considering the ramifications this will cause, for consistency, it should work the same as the 8bit ATmega. Also, it's not a feature at all, as a simple sketch like below won't work on the Teensy 3.0:

    Code:
    void setup() {
      Serial.begin(115200);
    }
    
    void loop() {
      Serial.println("Hello world!");
      while(1) {}
    }
    This sketch doesn't work on the Teensy 3.0, because you can never start the serial monitor fast enough to see the output.

    It's also a complex task for testing. You can't hit the reset button on the Teensy 3.0 when the serial monitor is open. So, to do multiple tests you need to always, close serial monitor, reset button, wait, open serial monitor. This is on top of adding a several second delay to the start of every sketch. If you don't exactly follow these steps, it won't work. Forget closing the serial monitor before hitting reset, sorry, won't work.

    A different programming environment is a moot point as Teensy 3.0 is designed to work in the Arduino IDE, as it should.

    Tim
    Last edited by teckel; 11-14-2012 at 06:20 PM.

  5. #5
    Senior Member
    Join Date
    Oct 2012
    Location
    Portland OR
    Posts
    706
    Teensy 3 does not yet auto-restart on serial port reset in the way 8-bit Arduino does, but that feature is planned. Due to the way Teensy 3 does USB, it is a non-trivial task.

    See "Missing Features, Coming Soon...." at this post
    http://www.kickstarter.com/projects/...a/posts/331757
    and also:
    http://forum.pjrc.com/threads/118-Se...full=1#post334
    http://forum.pjrc.com/threads/118-Se...full=1#post340

  6. #6
    Junior Member
    Join Date
    Nov 2012
    Location
    Toledo, Ohio
    Posts
    10
    Thanks! Not being part of the Kickstarter, I didn't look there nor know that's where the known problems are listed. I did search these forums for serial problems, but didn't find that thread. Sorry for asking a duplicate question already answered.

    I would suggest a Teensy 3.0 forum with a sticky "known issues" thread. That would probably catch most problems like this.

    Tim

  7. #7
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    486
    Quote Originally Posted by teckel View Post
    Not considering the ramifications this will cause, for consistency, it should work the same as the 8bit ATmega. Also, it's not a feature at all, as a simple sketch like below won't work on the Teensy 3.0:

    Code:
    void setup() {
      Serial.begin(115200);
    }
    
    void loop() {
      Serial.println("Hello world!");
      while(1) {}
    }
    This sketch doesn't work on the Teensy 3.0, because you can never start the serial monitor fast enough to see the output.

    It's also a complex task for testing. You can't hit the reset button on the Teensy 3.0 when the serial monitor is open. So, to do multiple tests you need to always, close serial monitor, reset button, wait, open serial monitor. This is on top of adding a several second delay to the start of every sketch. If you don't exactly follow these steps, it won't work. Forget closing the serial monitor before hitting reset, sorry, won't work.

    A different programming environment is a moot point as Teensy 3.0 is designed to work in the Arduino IDE, as it should.

    Tim
    I ran into this too, so I use:
    while (!Serial && (i++ < 10*10)) { // or ~ 10 seconds
    digitalWrite(LEDpin, HIGH); delay(50); digitalWrite(LEDpin, LOW); delay(50); }

    This will hang around for about 10 s, or until the serial monitor starts -- best of both worlds

Tags for this Thread

Posting Permissions

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