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

Thread: Teensy 3.6 I2C port 3

  1. #1
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    302

    Teensy 3.6 I2C port 3

    Can anyone tell me how to access I2C port 3 (SCL3,SDA3) on Teensy 3.6, Wire3 does not exist.
    I guess the pins could be assigned, but what if you want to use 4 I2C devices with Teensy3.6?

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,074
    Quote Originally Posted by BriComp View Post
    Can anyone tell me how to access I2C port 3 (SCL3,SDA3) on Teensy 3.6, Wire3 does not exist.
    I guess the pins could be assigned, but what if you want to use 4 I2C devices with Teensy3.6?
    I2C is a shared bus system. If each device has a different address, you just put them on the same bus. Each I2C device will only answer when a query is sent to that address. Many devices have solder pads or similar mechanisms to control what the address is.

    If you are trying to use devices with fixed addresses that can't be changed, you can get I2C multiplexers that connect up to 8 separate I2C buses. You use an I2C command to switch which line the multiplexer is talking to.


    Looking at the pinout card for the Teensy 3.6, there are 4 I2C buses:
    • SDA0/SCL0 -- Pins 19/18;
    • SDA1/SCL1 -- Pins 38/37;
    • SDA2/SCL2 -- Pins 4/3; (and)
    • SDA3/SCL3 -- Solder pads 56 and 57 underneath the Teensy.


    In addition, the Teensy supports alternate pins for several of the I2C buses. You could presumably re-init the I2C bus and use the functions to change to the alternate pins between device queries. How well this works in practice, I don't know. I suspect an I2C multiplexer would be simpler to use:
    • SDA0/SCL0 -- Alternate pins 16/17, 8/7, 34/33, and solder pads 48/47;
    • SCL2 -- Alternate pin 26.

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    302
    Wire, Wire1, and Wire2 are available for the various channels but there is NO Wire3 for the Teensy 3.6 which HAS 4 I2C channels.

    I know all about I2C but there would seem to be NO support for the 4 Teensy 3.6 channels, only 3.

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,692
    The i2c_t3 library provides access to Wire3. See the example scanner in examples/i2c_t3/advanced_scanner which scans all four I2C busses.

    Pete

  5. #5
    Senior Member
    Join Date
    Apr 2014
    Location
    Cheltenham, UK
    Posts
    302
    Thanks Pete, yes I see that that works but I was importing the Wire library and trying to use it with Wire3 as below which produced the following error "error: 'Wire3' was not declared in this scope".

    I thought that Wire was the default library to use for I2C. It is certainly the library referenced on the PJRC web site.
    Code:
    Wire3.begin();

Posting Permissions

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