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

Thread: Are SCL2/SDA2 functions of the T4.1 usable?

  1. #1

    Are SCL2/SDA2 functions of the T4.1 usable?

    Hi all,

    I am trying to talk I2C via SCL2/SDA2 of the T4.1 but not success. The SCL2 pin is constantly low with no transitions due to I2C writes.

    The setup is as follows

    Code:
    Wire.setSCL(24);
    Wire.setSDA(25);
    Wire.begin();
    The documentation at https://www.pjrc.com/teensy/td_libs_Wire.html says that settings the SCL/SDA pins is supported for Teensy LC and 3 only but this doesn't make sense (?).

    Any suggestions how to make SCL2/SDA2 to work?

    Thanks,
    Z.

  2. #2
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    266
    @zapta:

    Check <this thread> to see if it answers the same question that you are asking . . .

    Mark J Culross
    KD5RXT

  3. #3
    Thanks Mark, this is very useful.

    It that thread they initialized the display library to use the bus of choice but the MPU6050 library I am using seems to be hard coded to use Wire.

    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire2, OLED_RESET);

    Any idea how to divert Wire to use SCL2, without having to manually edit source files of libraries managed by platformio?

    My other option is to change the pin assignment and respin the board.

  4. #4
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,832
    youll have to modify the source

  5. #5
    I used SCL2 for a OLED screen so I could also use the audio board like this:
    (Teensy 4.1)

    //=== Screen ================================================== ================= Screen


    #include <Adafruit_SSD1306.h>


    #define SCREEN_WIDTH 128 // OLED display width, in pixels
    #define SCREEN_HEIGHT 64 // OLED display height, in pixels
    #define OLED_RESET 4 // Reset pin #
    #define SCREEN_ADDRESS 0x3C // Found using scanner


    //Changed Wire to Wire2 for SCL2 and SDA2 Yeay!
    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire2, OLED_RESET);

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,486
    Quote Originally Posted by zapta View Post
    Any idea how to divert Wire to use SCL2, without having to manually edit source files of libraries managed by platformio?
    Sadly, there is no way to do that. NXP simply did not provide a signal path inside the chip for the Wire SDA & SCL signals to route to pins 24 & 25 where the Wire2 SDA2 & SCL2 signals are.

    To be more specific, each pin does have a multiplexer which software can use to configure 1 of 7-10 different signals to control the pin. So the ways each pin can be used depend on which 7-10 signals inside the chip NXP chose to connect to that pin's mux. It would be awesome if those muxes had dozens or hundreds of inputs so you could make any pin have almost any signal. But that's not the hardware we actually have. Wishing doesn't make it so (and believe me, I was in contact with people inside NXP and repeatedly asked for 4+ DACs in future chips... they're giving us just 1 DAC in the next chip).


    the MPU6050 library I am using seems to be hard coded to use Wire.
    Yup, almost all older libraries using I2C are hard-coded for Wire.

    Newer libraries often have a constructor or other way to specify which port to use.


    My other option is to change the pin assignment and respin the board.
    Yes, confirmed, your two options basically boil down to software to make use of Wire2 or hardware so the I2C chip is connected to pins for Wire rather than pins for Wire2. If you're already planning any other PCB changes, or if you just *really* don't like editing software, maybe a hardware change is the easier path?

  7. #7
    Senior Member
    Join Date
    Oct 2019
    Posts
    188
    Quote Originally Posted by zapta View Post


    Any idea how to divert Wire to use SCL2, without having to manually edit source files of libraries managed by platformio?
    You can define in your library's source file the following:

    Code:
    #define Wire Wire2
    I did this with an Adafruit library and it works. It's an effortless and harmless edit that's easy to revert

  8. #8
    Quote Originally Posted by PaulStoffregen View Post
    Sadly, there is no way to do that. NXP simply did not provide a signal path inside the chip for the Wire SDA & SCL signals to route to pins 24 & 25 where the Wire2 SDA2 & SCL2 signals are.
    Paul, the association between the 'Wire' variable and the hardware is done in the teensy I2C driver implementation, right? If so, what prevents you from allowing users to control that association? E.g using a runtime method Wire.SetHardware(...), or a build time flags such as -D WIRE_HARDWARE=WIRE_HARDWARE_X.

    I may go with the new PCB layout option, though stitching the mod wires on the existing prototype PCBs I have is kind of a pain. ;-)

    @rezo, my goal is to not modify the libraries and let platformio manage them. I would define a global -D Wire=Wire1 but this will affect the entire build and may be difficult for me to understand all the implications.

Posting Permissions

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