Can the UARTs on the Teensy 4.1 be allocated to alternate pins?

garymq

Member
The Teensy 4.1 has 8 UARTs which have default pins, e.g. RX2, TX2 go to pins 7,8.

However, the Teensy 4.1 processor (IMXRT1062XRM) has an "IOMUX" capability which seems to allow pins' functions to be changed and re-allocated.
I'm wading thru the processor manual trying to figure out how this works.

Has anyone used this capability, and specifically, does anyone know if it can be used to shift the position of the UART pins?
If so, can this be used within the Arduino framework?

Thanks
 
Yes some of the pins, do allow to you to use some other specific pins.

The product card tries to show you the default pin and alternates:

For example for Serial1
The default pins for RX and TX are (0 and 1), but there are alternates on the back of 52 and 53
You will notice on the card it shows with lighter color and gray text instead of black...

The Hardware Serial class has methods to allow you to choose (setRX and setTX)
So for example you can do: Serial1.setTX(53);
And it should allow you to use those pins.
Likewise Serial1.setRX(52);

As you may notice there are only a few of these alternate pins.

For RX, (and CTS), there is another set of pins that can be used. And that is any XBar pin. Note: On each UART you can only use one (or none) XBar pin for either RX or CTS
To choose one for RX, again the Serail1.setRX(2); Will try use use pin 2 for the RX and it is in my table of XBAR pins in HardwareSerail.cpp...

Unfortunately, there was not enough room on the Cards for Paul to fit everything, so I don't think it shows you which pins are XBAR...
From image of my excel page... You can see the XBar pins marked in Green.
Screenshot.png

That is more or less it as far as using the HardwareSerial IOMUXC stuff.

In addition to this, there is the ability to use FlexIO pins to try to make your own types of things.
There is a copy of my FlexIO library (https://github.com/KurtE/FlexIO_t4) now in Teensyduino, where I have some somewhat limited Serail object, that can be configured to be TX only, RX only or both. And they use the FlexIO pins that are marked in Yellow in the above image. More if you are interested and/or look at the Readme file:
 
Thanks very much Kurt for the quick response.

That's just the sort of thing I was looking for... I'll try that out.

BTW that's a useful diagram.

Best Rgds, Gary
 
Back
Top