Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 12 of 12

Thread: Teensy 4.1 Serial Communication in 8E1 Configuration

  1. #1
    Junior Member
    Join Date
    Mar 2023
    Posts
    6

    Teensy 4.1 Serial Communication in 8E1 Configuration

    Hello,

    I'm trying to use Teensy 4.1 to communicate with a device that only uses 8E1 data format in terms of serial communication. I read on PJRC website that Teensy 4.1 doesn't support Serial1.begin(baud, format), so I'm assuming it only communicates in 8N1. Is there a way to still communicate with my target device through some clever coding/software methods? I can only think of somehow appending the parity bit to my outgoing bit stream from Teensy but have no idea how to achieve this. Thank you in advance for reading and helping!

    Yubo

  2. #2
    You should be able to use the format argument. Have you tried it?

    Code:
      Serial1.begin( 9600, SERIAL_8E1 );

  3. #3
    Junior Member
    Join Date
    Mar 2023
    Posts
    6
    Hi,

    Thank you for your reply. No, that function doesn't work. Here's what I'm seeing on Teensyduino. This code works on an Arduino Mega.
    Click image for larger version. 

Name:	teensy_error.jpg 
Views:	19 
Size:	79.1 KB 
ID:	30615

  4. #4
    Senior Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    158
    Serial and Serial1 are different technologies. Serial is the emulation over USB. Serial1 is a traditional UART

  5. #5
    Junior Member
    Join Date
    Mar 2023
    Posts
    6
    Thank you for your reply. I got rid of Serial.begin(38400, SERIAL_8E1) and the rest of the code seemed to be able to compile. It seemed that this section of the PJRC website might be out of date: Click image for larger version. 

Name:	teensy_4.1.jpg 
Views:	14 
Size:	48.8 KB 
ID:	30616

  6. #6
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    1,135
    Why out of date? It explicitly states Serial1.

  7. #7
    Junior Member
    Join Date
    Mar 2023
    Posts
    6
    Hi, yes it is referring to Serial1; however, it also says that Serial1.begin(baud, format) is only supported on Teensy LC and 3.x, not Teensy 4.x. I'm using a Teensy 4.1 and it seems to be compiling just fine. I posted the initial question assuming that Teensy 4.1 does not allow for data format configuration, based on what I read from the website. This is the URL for the website: https://www.pjrc.com/teensy/td_uart.html

  8. #8
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    1,135
    Ok, gotcha.

  9. #9
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,417
    Paul has a github project to track issues about the website.

    Did a quick look, and sure enough, I opened up an issue about this, about a year ago:
    https://github.com/PaulStoffregen/We...ates/issues/26

  10. #10
    Junior Member
    Join Date
    Mar 2023
    Posts
    6
    Hi Kurt, thank you for looking into this. Just to double check, this means that I can indeed configure the serial data format to be 8E1 using Serial1.begin(baud, format) on Teensy 4.1, correct? My Teensy 4.1 hasn't arrived yet, so I'm only checking whether it compiles on Teensyduino without testing the actual hardware.

  11. #11
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    11,417
    Yes you should be able to do 8E1. Don't remember if you need to enable 9 bit support within HardwareSerail or not, probably not.

    By default, the support for 9 and 10 bit and more is disabled within the source code as it requires the queues to be changed from 8 bits to 16 bits, which eats up a memory...

  12. #12
    Junior Member
    Join Date
    Mar 2023
    Posts
    6
    Hi Kurt, thank you for confirming. It appears that we only need HardwareSerial.h with serial data in the Serial_9X1 format, so we don't need to enable 9 bit support when the data bit is less than 9.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •