Teensy 4.0 Serial USB baud rate

Status
Not open for further replies.

False

Active member
Hello,

I am trying the teensy 4.0 as a usb to serial converter, I want to test its latency performances.
My build is :
PC <--> teensy 4.0 as a usb to serial converter <--> teensy 3.6

My issue/question is : the teensy 4.0 Serial.init doesn't seem to respect at all the baudrate parameter, is there any way to set the teensy serial baudrate ? What rate is it currently working at (seems like I am getting 230000 lines/sec average) ?
 
Last edited:
That is correct. Serial.begin( 'number' ); ignores the number and simple connects to the Host device at maximum USB connect speed as it is a true USB device, it does not set a baud rate to talk to an external chip to interface to the host.

For the T_4 to then connect to the T_3.6 through a UART Serial port in the programmed sketch the Serial#.begin( 'UART_baud' ) statement has the required 'UART_baud' to set the baud rate for the 'serial converter' function.
 
Yes - thanks for the answer - that's what I did so far but somehow when I read data back from teensy it's corrupted. It acts exactly the same as when I set a wrong baudrate in the arduino serial console in the old versions. So I was wondering if it was a different speed communication issue.
Is there any maximum baud rate for the teensy 3.6 serial interface ? Could I basically set a 480000000 rate between the teensy 4 and teensy 3.6 ? What would be the optimal communication between 2 teensy ?
 
The Serial UART hardware can not approach USB speeds - 2 M baud should work reliably - the T4 can clock just over 5 M baud - but the T_3.6 beyond 3 or 4 M baud IIRC can get lossy.

With good RX and Tx and GND wires between the two it should run well at compatible speeds.
 
For reliable high speed serial (not USB) between boards, the 2 keys to success are RTS/CTS flow control and FIFOs.

On Teensy 3.6, only Serial1 & Serial2 have FIFOs. All the serial ports on Teensy 4.0 have FIFOs.

Only some ports have CTS pins available. Also, I'm not sure of the status of RTS/CTS flow control on Teensy 4.0. Kurt wrote that code and I recall there was a caveat about flow control. I have not yet tested it.

Without RTS/CTS flow control, you have to be extremely careful about the timing your code uses to read the incoming data. While that is theoretically possible, in practice it's so incredibly difficult and so prone to breakage if you later modify your code that I would not recommend attempting fast baud rates (over ~500 kbits/sec) without RTS/CTS flow control.

Of course, good quality wires are required between. For high speeds, it's best to use CAT5 or CAT6 cable, where each twisted pair has a single signal and ground. That works out nicely, because you get 4 pairs in those cables and you need 4 signals when RTS & CTS are added. Many people who've run into problems neglected ground wires. The faster you run, the more important good ground wires are.
 
Regard the maximum baud rate question...

On Teensy 4.0, I believe it's 6 Mbit/sec. All 7 serial ports are identical hardware on Teensy 4.0.

On Teensy 3.x, Serial1 & Serial2 are capable of higher speeds. I believe the max if F_CPU / 16.

On both, the baud rate number you use gets rounded up or down to the nearest discrete step the hardware can actually generate. Those discrete steps become larger at the top end of the usable rate, because the hardware is dividing fast clocks by integers, plus some oversampling tricks to give you somewhat finer steps. Those oversampling tricks are different on Teensy 3.x vs 4.0. Usually you can get very close to your desired baud rate. Usually.

But if you value your sanity, I'd highly recommend setting the baud rate on both sides to something fairly slow, like 250000 or 500000, as you work on getting everything else running properly. Then later try increasing the speed, when you know your code is correct and your hardware is wired properly. Pushing the speed limits while you're still troubleshooting everything else is a sure recipe for frustration.
 
Status
Not open for further replies.
Back
Top