Teensy 4.1 Workaround Assigned Uart Pins

Boberman

New member
Hello Everyone,

I’m currently working on a project that uses the Teensy 4.1. As we move forward to a new iteration of our prototypes, there are some changes in the wiring, but we’d still like to maintain compatibility with the old prototypes.

At the moment, we are using Serial6 to both send and receive data at 115200 baud, but we now need it to receive data at a higher baud rate — around 2,000,000 baud — while continuing to send at the same slower rate of 115200 baud.

Since pins 0-41 are already in use in the new design, the wiring can’t be changed easily. Ideally, we’d like to assign two different UARTs to pins 24 and 25, with one UART for sending and the other for receiving. However, based on my current understanding, this may not be possible.

This leads me to wonder: could it be possible to use the hardware UART to receive data at the higher baud rate, deactivate the sending functionality, and then use a Software UART on the available pin to send at a slower baud rate? In theory, the baud rate for sending could also be lowered further, if necessary.

I’m curious if anyone has attempted something similar or has insights into how this could be done. Any suggestions or advice would be greatly appreciated!
 
Sadly, pins 24 and 25 don't have FlexIO or XBAR capbility, so SoftwareSerial is looking like your only option.

SoftwareSerial has been broken on Teensy 4.x until only recently. You'll need to grab the latest SoftwareSerial from github.

In Arduino IDE preferences, turn on verbose output during compile. Then when you compile, look for the info about which libraries it actually used. Make sure Arduino IDE is really using the fixed copy. The old version will compile, but it just uses the hardware serial ports and we only useful for running programs hard-coded to need "SoftwareSerial" class. Only the new version actually does bitbang.

The new version should work at 115200. But it can really have adverse effects on other libraries, so if you're simultaneously receiving at 2Mbit on Serial6, you might lose incoming data if SoftwareSerial blocks interrupts for too long. There is no realistic workaround, as that's simply the nature of timing sensitive bitbanging. But at least knowing the potential problem might help you do some early testing, rather than have a highly unpleasant experience where things seem to work at first, but then fail in difficult to reproduce ways later.
 
Thanks for the quick reply and the helpful info!

One quick follow-up: Are there any pin steps necessary to deactivate sending on serial6 so there are no interferences for the software uart on that pin ?

Thanks again!
 
Back
Top