Serial port behaviour with delay() on Teensy LC

Status
Not open for further replies.

Catherine

Member
I have a Teensy LC which I ordered through sparkfun. I also have an arduino uno for comparison.

This is the code I am trying to run:

Code:
void setup()
{                
  Serial.begin(9600);
}
int my_frame = 0;
void loop()                     
{
  Serial.print("frame: ");
  Serial.println(my_frame);
  my_frame += 1;
  delay(250);
}

When I run it on the arduino, it works as expected - it prints out the frame every 1/4th of a second, and the numbers are in sequential order.

When I compile and upload the code to the Teensy LC, it prints nothing.

If I change the delay to 50, it prints things out, but in bursts and not in sequential order:
frame: 73
frame: 76
frame: 77
frame: 78
frame: 79
frame: 92
frame: 101
frame: 136
frame: 137
frame: 138
frame: 139
frame: 143

while the arduino continues to operate as expected.

Is this due to some physical limitation of the board, or a difference in the implementation of the USB serial connection?
 
My LC, one of the first batch afaik, ran your sketch with expected result; sequentially every 1/4 second no misses - maybe your LC is defective?
 
I'm running it here on a Teensy-LC. I can't reproduce the problem.

screen.png
(click for full size)

I'm running Arduino 1.6.7 on Linux 64 bit. Which operating system are you use?
 
Maybe another device (like that Arduino Uno) is still connected and somehow both are using the same serial device name or com port number?

Maybe test with the Uno completely unplugged from your computer?

Also, try closing and reopening the serial monitor. Teensy and Arduino use different Java code for their serial monitors. If you leave the window open between the 2 boards, you might end up with the wrong one running. But still, I can't imagine how that could explain this very strange problem.

We've seen problems before where data is missing when 2 program access the same port. But out of order data is very odd.
 
That seems like it should work right off - delay is odd but shouldn't mess with that. Teensy's tend to start faster - and the USB is not hardware based.

Go to this post and copy the sketch there: communicate-with-Teensy

You can modify the "." print loop to use your 'frame' output. It uses a no delay()wait to limit printing to once per second ( the 1000 ).

It also shows a wait in setup() for the USB to connect to the PC (and SerMon from the IDE) with the while() loop.

It will also blink the LED each loop so you can see it running smoothly.

You can take some of that same code back top your sample perhaps ( the while() and qBlink in setup() - then add a qBlink in loop() to see it running ) and it may change your results even with the delay().
 
Any chance you could try on a different computer?

My guess is something is seriously messed up with that Ubuntu machine.
 
Any chance you could try on a different computer?

My guess is something is seriously messed up with that Ubuntu machine.

Unfortunately, I don't currently have another linux machine to compare against, but I think you are right - it works perfectly fine on my windows vista computer.
 
Also, make sure the modemmanager isn't trying to talk to Teensy. The udev rule is supposed to tell it to leave Teensy alone.
 
Status
Not open for further replies.
Back
Top