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

Thread: link a teensy 4.1 to an arduino mega 2560 R3

  1. #1

    link a teensy 4.1 to an arduino mega 2560 R3

    I want to link a teensy 4.1 to an arduino mega 2560 R3.

    What is the best way to hook these two together to exchange data? Serial? a parallel bus? SPI etc? Are there any libraries available to handle this?

    What to do about the 3.3v to 5v and visa versa?

  2. #2
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,368
    You can use serial, the Arduino Mega has 4 serial interfaces. You'll need a level converter for each direction, but at a
    pinch you can use a resistive divider 1k:2k2 for 5v->3.3V and just directly connect for 3.3V->5V, since the Arduino will
    recognize 3.3V as HIGH.

    However a level converter is a safer option.

  3. #3
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,905
    safer to protect the teensy tx pin should you misprogram the mega and shoot 5v down the line. You could always go with a Teensy 3.5 as it is 5v tolerant and will talk fine to mega directly wired with the uarts

  4. #4
    I keep running into dead ends on this. Im thiking I will be moving midi over the serial lines from the t4.1 to the mega and back. Now I wonder if I go with opto isolators as you would with a midi input. Or is there a good IC anyone can reccommend to handle this?

  5. #5
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    465
    What you want for a level shifter is an ADUM1201. They can be obtained ready mounted on breakout board like this.

  6. #6
    Junior Member
    Join Date
    May 2021
    Location
    Canada
    Posts
    9
    Quote Originally Posted by snowsh View Post
    I want to link a teensy 4.1 to an arduino mega 2560 R3.

    What is the best way to hook these two together to exchange data? Serial? a parallel bus? SPI etc? Are there any libraries available to handle this?

    What to do about the 3.3v to 5v and visa versa?
    That depends on several factors: How much data do you plan to transfer and how fast do you need it to happen? Over what distance? Are they gonna be powered from the same power rail?

    Unless you're gonna be sending a good amount of data (say beyond 100kbps), I'd go with Serial due to the dead simple wiring and buffered tx/rx queues, so you don't have to implement that yourself (Paul also seems to share of the same advice).

    Level shifting from 5v to 3.3v with a resistor divider works for slower speeds, say < 38400 baud. On my devices for serial communications over a couple of meters at 115200 I've been using 74HCT245s but I reckon you could even go with something simpler such as a mosfet shifter.

    As to what concerns a messaging protocol, again that depends on your needs. If you need something with a proper message queue, framing, checksumming etc you might want to look at TinyProto as well as this thread.

  7. #7
    Junior Member
    Join Date
    May 2021
    Location
    Canada
    Posts
    9
    Quote Originally Posted by rbfowler9 View Post
    Level shifting from 5v to 3.3v with a resistor divider works for slower speeds, say < 38400 baud. On my devices for serial communications over a couple of meters at 115200 I've been using 74HCT245s
    I stand corrected -- I've been using 74HCT245s to bump 3.3v up to 5v, not the other way around. For down converting you'll be looking at 74LV parts such as a 74LVC125 or a 74LVC245.

  8. #8
    Senior Member BriComp's Avatar
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    465
    I stand corrected -- I've been using 74HCT245s to bump 3.3v up to 5v, not the other way around. For down converting you'll be looking at 74LV parts such as a 74LVC125 or a 74LVC245.
    or some of these https://www.analog.com/media/en/tech...M1200_1201.pdf which are intended for that job, are compact and inexpensive.

Posting Permissions

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