Serial2 RX TX pin problem

Using a Teensy 4.1

According to official documentation the Serial2 has pin RX=7 ant TX=8

I do not set RX in my project and it seems that the RX pin is in my case pin8 and TX pin is pin9
I found this out just by trial and error reconecting cable
Do I have a faulty made board? Is there something I can do to fix this?

Is there a possibility to check the pin config of Serial ports?

A function that i can use in a sketch so i can see wich pin is de RX/TX port for Serial1..8?

Kind regards and hoping for an answer
 
Last edited:
Can we start by first knowing which Teensy model you have?

I'm guessing either Teensy 4.0 or Teensy 4.1, as those are the ones with Serial2 on pins 7 and 8.
 
I ran a quick test here, with this code.

Code:
void setup() {
  Serial2.begin(9600);
}

void loop() {
  Serial2.print("Test");
  delay(500);
}

I connected my oscilloscope to pins 7, 8, 9.

1700693073141.png


My scope is definitely seeing the output on pin 8 (green), not pin 9 (blue).

1700693114662.png
 
With Serial2.begin( baud ) pin 7 will then act as RX and pin 8 will be set for TX. It should make no changes to pin 9 or other.

Both of those pins will be found to be resting at 3.3V after the .begin() and ready for 'baud' rate UART I/O.
 
I can't say why you're seeing the signal on pin 9. It really makes no sense.

I can tell you every Teensy 4.1 is fully tested on a bed-of-nails test fixture which verifies every pin is properly connected and none are shorted to any others.
 
Is there a possibility to check the pin config of Serial ports?

Just to make sure I answer this question, there isn't an easy or convenient way. There's no API for this. And the way the underlying hardware works is based on configuration of each physical pin.

You could read the pin mux registers and check which function the pin has been configured to use.
 
Teensy's core library defines names for those registers in terms of the pin numbers. So you could read CORE_PIN8_CONFIG. Or you could read IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00, which is the NXP native register name. You could discover the native name by reading core_pins.h, or by reading the Teensy 4.1 schematic and noticing pin 8 is "B1_00", then find the full register name in the reference manual.

Either way, you'll need the reference manual to interpret the result. In this case, the info is on page 520.

1700693836096.png
 
Here is a copy of the test program which prints the pin 8 mux config.

Code:
void setup() {
  Serial2.begin(9600);
}

void loop() {
  Serial.println(IOMUXC_SW_MUX_CTL_PAD_GPIO_B1_00);
  Serial2.print("Test");
  delay(500);
}

When I run this, indeed it prints the number 2, because pin 8 really is configured to be controlled by the UART (the Arduino serial port numbers are different from NXP's native port numbers... LPUART4 really is Serial2... another detail discoverable by reading the core library code).

You could repeat this for pin 9, which is IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11. But if you look up IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11 in the reference manual, you'll see none of its settings cause any of the LPUART peripherals to be connected. There is literally no possible way to configure pin 9 (GPIO_B0_11) to be controlled by any of the serial ports. (but it can be controlled by FlexIO which can emulate a serial port... really only a possibility if you're using the FlexSerial from the FlexIO_t4 library)
 
ah ok , thx a lot for these quick answers :)

I ran the sketch and indeed i also get 2 as result
So there must be something else going wrong :-(

Maybe a short circuit between RX ant TX on Serial2?
That could maybe explain the correct reading on pin 8 (wich is normally the TX pin)???
Pin 7 gives me very strange results in fact.
And i assumed then that maybe pin 9 was the TX (but i didn't really test this)

Kind regards and tnx for the efforts
 
ah ok , thx a lot for these quick answers :)

I ran the sketch and indeed i also get 2 as result
So there must be something else going wrong :-(

Maybe a short circuit between RX ant TX on Serial2?
That could maybe explain the correct reading on pin 8 (wich is normally the TX pin)???

Kind regards and tnx for the efforts
Maybe share a photo or your connections? To verify which pins you are using, since Teensy pin numbering is not "standard".
 
It's rather difficult to share picture of connections.
I made a custom pcb board with connections based on documentation , and for Serial2(RX) I had to make a patch.
A picture of the pcb board will tell you nothing about the connections :)
When i look at my pcb-board layout and schematics, this corresponds with the www.prjc.com/teensy teensy4.1 connection layout

When i count the pins on the left of the teensy-board , my patch is connected to pin 10 ... When i count the pins on the documentation this corresponds to pin 8 (you have GND and counting starts from 0) 0= Serial1 RX
This pin8 works , my schematics were connected to pin7 (eq pin9 when counting pins starting from1) , this gave very strange results on input signal.

When i do
Serial.println(IOMUXC_SW_MUX_CTL_PAD_GPIO_B0_11);
i get result 5, is this ok?

I do not use the FlexIO_t4 library, i use
#include <Control_Surface.h>

But this lib uses a lot of other headerfiles and maybe i tought somewhere in there could be configuration to make this strange behavior happening
I could adapt my schematics ane pcb layout to use pin 9 , but maybe if i order a new teensy4.1 this will then be wrong again.
That's what i want to figure out
 
With the mux registers, 5 means the pin is controlled by GPIO (digitalRead or digitalWrite).

To conclusively see which libraries are actually used, in Arduino click File > Preferences (it may be Arduino > Settings on MacOS) and turn on verbose output during compile. You'll see a *lot* of info printed as Arduino IDE compiles your program. Near the end will be a list of the libraries it used, and if any duplicate libraries were found, you'll also see info about which libraries it didn't use.

Regarding which pin is which, hopefully your Teensy came with the pinout reference card? Best to keep that card handy while looking at the pins. As others have mentioned, we really can't help with the connections if we can't see your PCB layout or other wiring details. This is the only help I can try to give without being able to see.
 
I understand, i find it myself very strange and totally impossible, maybe there is another problem that i don't get for the moment

Yes my teensy came with the pinout reference card, and that's what i based my pcb layout on.
When i count the pins, on the reference card, from left top corner GND, 0,1,2,3,4,5,6,7(RX2) these are 9pins and my working connection is on pin 10 :(

I wil try to use another pcb of the same lot and also another new teensy4.1, who knows

Thx for your quick answers
 
Last edited:
Good news :)

I put this in my setup code
Serial2.setRX(7);
Serial2.setTX(8);

And everything works without patch cable.
So my pcb is correct, because that was my biggest concern
 
Back
Top