Can Teensy 3.x Hardware Serials do 7N1?

KurtF

Member
I've snooped through the megamanual and can't find any reference to 7 bit mode (aka M7 flag on Teensy 4.x) or how to achieve 7N1 format on the 3.x hardware serial ports. I was wondering if anyone had knowledge/experience with this.

For 7N1 on Teensy 4, I found a post in here, snooped that megamanual, and found someone was kind enough to annotate in the correct mappings for CNTRL registers and Serials. I came up with this, and have been using it to drive LEDs:

Code:
        Serial1.begin(baudKhz * 3000, SERIAL_8N1_TXINV);
        LPUART6_CTRL |= LPUART_CTRL_M7;  //Set 7N1

Thanks! Oh BTW... Teensy Serial ports are awesome LED drivers. :)
 
Last edited:
At a pinch you can use 8 bit mode with the top bit faking an extra stop bit...
Thanks, but I really need 7N1 for my app, and I was hoping to extend my app compatibility to Teensy 3.x.

My app is an LED display driver, and 3 bits is a 'magic' number for LED input. Only true 7N1 lets me use 3 serial bits to pattern one LED bit with spec pulse timing ratio (H 2/3 of the cycle, L 1/3 is recognized as LED 1; H 1/3, L 2/3 = LED 0). Using this format I get 3 LED bits per serial "byte", which is 50% better data density than all the other LED display apps I've seen using UART output. They send 2 LED bits per serial "byte" over 8N1. 7N1 is a 9-bit format and it works great on Teensy 4.0.

I can't find an "M7" mode bit or 7-bit reference in the Teensy 3.5 manual.
 
Last edited:
7N1 is a 9-bit format and it works great on Teensy 4.0.

I can't find an "M7" mode bit or 7-bit reference in the Teensy 3.5 manual.

I don't see anything in the manual, either. It clearly says 8-bit or 9-bit. What do you mean by "7N1 is a 9-bit format"?
 
I don't see anything in the manual, either. It clearly says 8-bit or 9-bit. What do you mean by "7N1 is a 9-bit format"?
In 7N1, I send 8-bit data with Serial1.write() but only the low 7 are significant. Serial hardware strips the high bit, then adds 1 start and 1 stop bit. The bytes I write are designed for the start/stop bits to result in a 9-bit 7N1 packet which the LED sees as 3 data pulses.
 
In 7N1, I send 8-bit data with Serial1.write() but only the low 7 are significant. Serial hardware strips the high bit, then adds 1 start and 1 stop bit. The bytes I write are designed for the start/stop bits to result in a 9-bit 7N1 packet which the LED sees as 3 data pulses.

LPUART chapter in T4 manual says 7, 8, 9, or 10 data bits. UART chapter in T3 manual says 8 or 9. I think that's your answer.

You haven't said anything about bit rate, but since it's speed you're after, you probably don't want to use a software uart.
 
LPUART chapter in T4 manual says 7, 8, 9, or 10 data bits. UART chapter in T3 manual says 8 or 9. I think that's your answer.

You haven't said anything about bit rate, but since it's speed you're after, you probably don't want to use a software uart.
Ok. I guess that blows my bad assumption that all UARTs are created equal. :)

Correct, I am looking for high refresh rates of large LED displays (ie- cubes) from non-blocking writes to all 7 Serials in parallel (interleaved). On Teensy 4, I get awesome speed test results, largely owing to how well the Hardware Serial library implements non-blocking buffered i/o.

I thank you (both) for your time!
 
Back
Top