Teensy 4.1 serial port polarity invert?

JMFORD

Member
Hi.

I am working on a system with the Teensy 4.1, and I was wondering if the INVERT function is supported as it is on the 3.X series. The Web page on serial ports seems to indicate that it is not, or maybe it's done in a different way.

I can build in an inverter for my hardware if need be, but it's obviously better to use the internal inverter if there is one.

Thanks!

John
 
The simple answer is it should be there:
We do have it defined in the header file:
Code:
#define SERIAL_7E1 0x02
#define SERIAL_7O1 0x03
#define SERIAL_8N1 0x00
#define SERIAL_8E1 0x06
#define SERIAL_8O1 0x07
#define SERIAL_7E1_RXINV 0x12
#define SERIAL_7O1_RXINV 0x13
#define SERIAL_8N1_RXINV 0x10
#define SERIAL_8E1_RXINV 0x16
#define SERIAL_8O1_RXINV 0x17
#define SERIAL_7E1_TXINV 0x22
#define SERIAL_7O1_TXINV 0x23
#define SERIAL_8N1_TXINV 0x20
#define SERIAL_8E1_TXINV 0x26
#define SERIAL_8O1_TXINV 0x27
#define SERIAL_7E1_RXINV_TXINV 0x32
#define SERIAL_7O1_RXINV_TXINV 0x33
#define SERIAL_8N1_RXINV_TXINV 0x30
#define SERIAL_8E1_RXINV_TXINV 0x36
#define SERIAL_8O1_RXINV_TXINV 0x37
#ifdef SERIAL_9BIT_SUPPORT
#define SERIAL_9N1 0x84
#define SERIAL_9E1 0x8E
#define SERIAL_9O1 0x8F
#define SERIAL_9N1_RXINV 0x94
#define SERIAL_9E1_RXINV 0x9E
#define SERIAL_9O1_RXINV 0x9F
#define SERIAL_9N1_TXINV 0xA4
#define SERIAL_9E1_TXINV 0xAE
#define SERIAL_9O1_TXINV 0xAF
#define SERIAL_9N1_RXINV_TXINV 0xB4
#define SERIAL_9E1_RXINV_TXINV 0xBE
#define SERIAL_9O1_RXINV_TXINV 0xBF
#endif
// We have 1/2 bit stop setting
#define SERIAL_2STOP_BITS 0x100
#define SERIAL_8E2 (SERIAL_8E1 | SERIAL_2STOP_BITS)
#define SERIAL_8O2 (SERIAL_8O1 | SERIAL_2STOP_BITS)
#define SERIAL_8E2_RXINV (SERIAL_8E1_RXINV | SERIAL_2STOP_BITS)
#define SERIAL_8O2_RXINV (SERIAL_8O1_RXINV | SERIAL_2STOP_BITS)
#define SERIAL_8E2_TXINV (SERIAL_8E1_TXINV | SERIAL_2STOP_BITS)
#define SERIAL_8O2_TXINV (SERIAL_8O1_TXINV | SERIAL_2STOP_BITS)
#define SERIAL_8E2_RXINV_TXINV (SERIAL_8E1_RXINV_TXINV | SERIAL_2STOP_BITS)
#define SERIAL_8O2_RXINV_TXINV (SERIAL_8O1_RXINV_TXINV | SERIAL_2STOP_BITS)
#define SERIAL_8N2 (SERIAL_8N1 | SERIAL_2STOP_BITS)
#define SERIAL_8N2_RXINV (SERIAL_8N1_RXINV | SERIAL_2STOP_BITS)
#define SERIAL_8N2_TXINV (SERIAL_8N1_TXINV | SERIAL_2STOP_BITS)
#define SERIAL_8N2_RXINV_TXINV (SERIAL_8N1_RXINV_TXINV | SERIAL_2STOP_BITS)
// bit0: parity, 0=even, 1=odd
// bit1: parity, 0=disable, 1=enable
// bit2: mode, 1=9bit, 0=8bit
// bit3: mode10: 1=10bit, 0=8bit
// bit4: rxinv, 0=normal, 1=inverted
// bit5: txinv, 0=normal, 1=inverted
// bit6: unused
// bit7: actual data goes into 9th bit
It has been awhile since I played with it... So you might give it a try.

Which reminds me, I still have some Pull Requests to check on
 
It inverts the logic. LOW<->HIGH. Standard serial uses HIGH for 'space', LOW for 'mark', and idles HIGH.
 
Yes, as Mark says. In my case, I am dealing with some custom fiber-optic transmitter/receivers that invert the signal, and I wondered if I have to continue with that or if I could invert the signal inside the chip so that I could maybe use a standard fiber optic transmitter on one end and keep the inverting one on the other end. I've got a teensy 4.1 on order, so we soon shall see!
 
Yes, as Mark says. In my case, I am dealing with some custom fiber-optic transmitter/receivers that invert the signal, and I wondered if I have to continue with that or if I could invert the signal inside the chip so that I could maybe use a standard fiber optic transmitter on one end and keep the inverting one on the other end. I've got a teensy 4.1 on order, so we soon shall see!

/resurect

Did you get this working for the 4.1?

I noticed on this page that it may only be supported on Teensy LC, 3.0, 3.1, 3.2, 3.5, 3.6?
 
/resurect

Did you get this working for the 4.1?

I noticed on this page that it may only be supported on Teensy LC, 3.0, 3.1, 3.2, 3.5, 3.6?

It should be working. Those comments are out of date. I believe it was trying to say at the time, not supported on Teensy 2...
 
Back
Top