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

Thread: Seeking advice on communication between two Teensy 4.1 boards

  1. #1

    Seeking advice on communication between two Teensy 4.1 boards

    Hi,

    I am designing a custom PCB that will mount 2 x Teensy 4.1 boards side by side that represent two sub-systems of the same project. Lets call them Teensy A and Teensy B. Teensy A needs to send some very light weight data to Teensy B, as it gathers info from its attached sensors/inputs etc. The data basically takes the form of a stream of numerical value pairs. The data is not bidirectional - it's just a one way stream.

    I had initially assumed using one of the SPI busses would be ideal for this, except after doing lots of reading on this forum I now see that Teensy (or Arduino) as SPI Slave is not part of the official SPI library. I have previous experience using I2C between multiple Teensy 4.1 boards using Richard Gemmell's outstanding teensy4_i2c library - so that's an option I have up my sleeve... however for this particular application I just want a simple interrupt to happen when new bytes arrive at Teensy B so I wonder if a simpler type of serial data is more appropriate.

    I'm just looking for some advice from anyone with experience on this - what the best interface to use for this scenario? Is a plain-old single wire Hardware Serial pin the way to go, with a pre-agreed data rate? Or does that expose me to potential errors without a separate hardware clock pin like SPI or I2C would use? Again, the two boards will be very close together, simply connected by traces on the same PCB that physically mounts them.

    Cheers,

    Josh
    Last edited by lrtjosh; 03-16-2021 at 11:30 AM. Reason: Changed "1-wire" to "single wire" to avoid confusion

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,150
    what is the required data rate?

  3. #3
    Quote Originally Posted by WMXZ View Post
    what is the required data rate?
    Nothing fast - ultimately midi rate (31,250bps) would be fine but I'll crank it as fast as it can reliably go for whatever serial buss type is used.

  4. #4
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    186
    I haven't got any experience with SPI, but I would use simple UART serial.

    It's already done for you and would be so simple to get going.

    If you want handshaking then rts/cts is available to you, but I can't imagine why you would.

    Just invent a character sequence which indicates the start of a data packet and either send or have a pre-determined data length or a pre-determined end of data character sequence.

    If you were simply sending text it could/would be CRLF.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,078
    I’d also recommend using serial. If the message is always the same data type, you could you a library like EasyTransfer if you don’t feel like writing code to parse the received bytes into the data fields.

  6. #6
    Thanks @BriComp, that's helpful! Simplicity is good. I guess when using UART, the issue of not having a separate clock signal is mitigated by the fact that the receiving chip is using hardware features and not just randomly timed software serial?

  7. #7
    Quote Originally Posted by PaulStoffregen View Post
    I’d also recommend using serial. If the message is always the same data type, you could you a library like EasyTransfer if you don’t feel like writing code to parse the received bytes into the data fields.

    Thanks Paul, I'll check out EasyTransfer!

  8. #8
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,029
    Quote Originally Posted by BriComp View Post
    I haven't got any experience with SPI, but I would use simple UART serial.

    It's already done for you and would be so simple to get going.

    If you want handshaking then rts/cts is available to you, but I can't imagine why you would.

    Just invent a character sequence which indicates the start of a data packet and either send or have a pre-determined data length or a pre-determined end of data character sequence.

    If you were simply sending text it could/would be CRLF.
    IIRC on the Teensy 4.0 you only have 2 CTS pins, both of which are inconvenient locations. Teensy 4.1 has a 3rd CTS pin, also in an inconvenient location:
    • Pin 19 on Teensy 4.0/4.1 is CTS3. Unfortunately, pin 19 is the SCL pin for the main I2C bus;
    • Pin 35 on Teensy 4.0 and pin 43 on Teensy 4.1 is CTS5. Unfortunately this pin in the middle of the pins for the micro SD card reader; (and)
    • Pin 50 on Teensy 4.1 is CTS8. Unfortunately this pin is used for the two flash/PSRAM pads underneath the Teensy.

Posting Permissions

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