Teensy 4.0: mixed up Tx & Rx for Serial2

thefloe

Member
Hi,
On a custom board for the Teensy 4.0 I managed to swap the Rx and Tx pins for Serial2. Am I correct that the pins cannot be remapped/swapped in software? Just want to be sure before reworking some batch of boards.
Thank you in advance,
T
 
Simple answer, no these pins can not be remapped to be swapped.

However if you only needed RX, you might be able to cheat.

Possibly two ways:
a) Set the TX pin to be in half duplex mode and leave it in RX mode...
b) You can use an XBAR pin for the RX pin of any Uart. The code has to setup some XBar mappings and the like, which the setRX method takes care of. And pin 8 is an XBAR pin. so it will accept that.
However I don't know any way to map pin 7 into being a TX pin for the uart.

Or if you are in a pinch, both of these pins are FlexIO pins and we do have code in the FlexIO library to create a psuedo Serial port using flexIO pins.
There are a couple of examples like in: https://github.com/KurtE/FlexIO_t4/blob/master/examples/FlexSerial_Both/FlexSerial_Both.ino

But probably your bet is to maybe rework the boards.
 
Good idea on receiving with xbar.

For transmit on pin 7, you could try using SoftwareSerial. It can't receive if the 2 pins you select are not a real serial port. Maybe configure SoftwareSerial to transmit on pin 7 and receive on some pin you're not using, like one of the bottom side pins. But SoftwareSerial is pretty inefficient. May or may not be a good idea depending on the rest of your code.

FlexIO is probably the best solution short of cutting PCB traces.
 
Thanks for the suggestions and comments!

In this case I'm going to cut the traces... I need to send and receive. I have in total 3 Serial Ports at 115200baud and quiet some other stuff to do on the Teensy. Guess performance wise it's better to use a hardware serial.
 
Back
Top