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

Thread: Wire3 on teensy 3.6?

  1. #1
    Junior Member
    Join Date
    Nov 2018
    Posts
    18

    Wire3 on teensy 3.6?

    Hi!

    Im currently working on a project where it would be very beneficial to use all 4 I2C on the teensy 3.6.

    However,

    Wire.begin() //Works fine
    Wire1.begin() //Works fine
    Wire2.begin() //Works fine
    Wire3.begin() //'Wire3 was not declared in this scope

    Tested on both Platformio and Arduino ide with latest Teensyduino installed. Wire3 even gets highlighted in Arduino Ide, but it doesnt work.

    Any thoughts?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,432
    Go into the Wire library into the file WireKenitis.h

    You will see the section for T3.6
    Code:
    // Teensy 3.6
    #elif defined(__MK66FX1M0__)
    #define WIRE_IMPLEMENT_WIRE
    #define WIRE_IMPLEMENT_WIRE1
    #define WIRE_IMPLEMENT_WIRE2
    //Wire3 is seldom used on Teensy 3.6
    //#define WIRE_IMPLEMENT_WIRE3
    #define WIRE_HAS_START_INTERRUPT
    #define WIRE_HAS_STOP_INTERRUPT
    Uncomment the define and you will have Wire3

  3. #3
    Junior Member
    Join Date
    Nov 2018
    Posts
    18
    Thanks! Now it at least compiles Up to test tomorrow.
    Wonder why it was commented out?

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,535
    It was commented out because each declared WIRE instance eats up a few system resources, if used afterwards or not. And WIRE3 is a fourth I2C bus. Seen that each bus can theoretically handle 120 devices, under condition of thoughtful addressing, this fourth wire instance would only be needed from the 361st peripheral...

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,599
    Quote Originally Posted by Frassil View Post
    Wonder why it was commented out?
    As mentioned earlier, each one eats up some RAM even if not used.

    Almost nobody uses Wire3, parly because Wire, Wire1 and Wire2 meet almost everyone's needed, but also because Wire3's pins are only on the bottom side pads.

    In fact, as far as I can recall, this is the first time in 2 years anyone has even asked about how to use Wire3.

  6. #6
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,080

  7. #7
    Junior Member
    Join Date
    Oct 2019
    Location
    Germany Maintal
    Posts
    10
    Hi Paul,

    i want to use wire3, because the other wires use pins, witch are shared with functions i need.

    But i will commen out wire1 and wire 2.

    Thank You
    Lothar

  8. #8
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    5,432
    Wondering what would happen if we moved each of the wire objects with their own ISR to their own .cpp file. Then hopefully only those objects actually referenced would be created and use memory?

Posting Permissions

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