Forum Rule: Always post complete source code & details to reproduce any issue!
Page 1 of 2 1 2 LastLast
Results 1 to 25 of 29

Thread: second spi channel ?? teensy 4.1

  1. #1
    Senior Member
    Join Date
    Apr 2020
    Location
    Guelph Ontario Canada
    Posts
    116

    second spi channel ?? teensy 4.1

    I recently received a weird 7.85" 1280 x 400 TFT display ...

    I did a search and I found a few posts where people have them working and I checked github so there is hope ...

    anyhow it uses an ra8876 for the graphics portion and it has a secondary chip which is used initially to set up the mode of operation .. both of them require SPI ..

    if I remember correctly the tri-state behaviour of the ra8876 is questionable and I would like to allocate 1 spi channel to the display driver .. and the second spi channel to the setup chip ..

    I'm currently running a teensy 4.0 but have e 4.1's on order and will probably migrate to the 4.1 processor...

    can somebody point me in a direction for implementing 2 SPI channels on the teensy 4.1 so I can bypass the tri-state issue with the ra8876?

    OR if there is a better solution .. I'm all ears

    thanks
    K
    Last edited by Keith_M; 08-11-2020 at 08:36 PM. Reason: typo

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    One of these? https://www.buydisplay.com/spi-1280x...ve-touch-panel

    If so you might take a look at our RA8876 driver that a few of us have been playing with:
    https://github.com/wwatson4506/Ra8876LiteTeensy

    Note: Currently you need to use the other branch of the library: https://github.com/wwatson4506/Ra887...sy-ER-TFTM0874
    I have an open Pull Request to that branch to hopefully make it compatible with the other RA8876 boards we are using (1024x600), hopefully when a few people try out my PR to make sure it still works for the display I think you have, we will get this PR pulled into the branch I mentioned and then that branch PRd into master...

    More details in the thread https://forum.pjrc.com/threads/58565...sy-T36-and-T40

    As for MISO pin. You have a couple of issues. Use a secondary SPI port like SPI1.
    With MOSI1=26, SCK1=27, MISO1 = (1, 39) Note pin 1 is default to use 39 SPI1.setMISO(39); THere are a few hardware CS pins, not really used on this device so can be any digital pin.

    My adapter board, I have the option to put in a buffer to make it tristate. But the one board I populated, I shorted this out as I only use this display to test, so did not matter that other SPI devices may not work with it.

  3. #3
    Senior Member
    Join Date
    Apr 2020
    Location
    Guelph Ontario Canada
    Posts
    116
    WOW .. KurtE .. thanks for the links and all ..greatly appreciated .. was not expecting that .. !!!
    Last edited by Keith_M; 08-12-2020 at 03:09 AM. Reason: typo

  4. #4
    Senior Member
    Join Date
    Apr 2020
    Location
    Guelph Ontario Canada
    Posts
    116
    Hi KurtE .. I took a look at the code for the 7.84" display .. I'm good for the connection on the RA8876 standard SPI

    ER_TFT0784_t3 tft = ER_TFT0784_t3(
    // Teensy pin // Display pin
    10, // RA8876 CS 5
    14, // RA8876 RESET 11
    11, // RA8876 MOSI 7
    13, // RA8876 SCLK 8
    12, // RA8876 MISO 6

    But struggling where the SSD2828 Connections go on t4.1

    36, // SSD2828 CS 31
    38, // SSD2828 RESET 43
    4, // SSD2828 SDI 34
    37 // SSD2828 SCK 35
    );

    Could you provide me with some direction with respect to the SSD2828 pinout for the teensy 4.1 ?

    Thanks
    K

  5. #5
    Senior Member
    Join Date
    Apr 2020
    Location
    Guelph Ontario Canada
    Posts
    116
    Does this make sense ?... ( Sorry I lack going beyond 1 device on SPI ..So uncharted ground for me LOL

    SSD2828 CS T4.1 Pin 38 CS1
    SSD2828 RESET T4.1 Pin ???
    SSD2828 SDI t4.1 Pin 26 MOSI1
    SSD2828 SCK T4.1 Pin 27 SCK1
    );

    not quite sure what to do with the reset..
    Last edited by Keith_M; 08-27-2020 at 03:47 PM. Reason: additional data

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    Reset Depends on the device some work without using a IO pin and may or may not need to be connected to some voltage (either high or low... depending on device)...
    As for pins for SPI1, you look like you have the right pins for SCK1 and MOSI1.

    As for CS pin, can probably be any IO pin, unless the device is doing some very T4.x hardware specific.
    38 is a valid hardware SPI pin for SPI1, but again most devices don't do anything special with CS (that is they use something like digitalWrite to set and clear it.

  7. #7
    Senior Member
    Join Date
    Apr 2020
    Location
    Guelph Ontario Canada
    Posts
    116
    Quote Originally Posted by KurtE View Post
    Reset Depends on the device some work without using a IO pin and may or may not need to be connected to some voltage (either high or low... depending on device)...
    As for pins for SPI1, you look like you have the right pins for SCK1 and MOSI1.

    As for CS pin, can probably be any IO pin, unless the device is doing some very T4.x hardware specific.
    38 is a valid hardware SPI pin for SPI1, but again most devices don't do anything special with CS (that is they use something like digitalWrite to set and clear it.
    Thanks Kurt .. Well .. I'll run it up and see what happens .. if I can get it to light up and run a demo .. I can go from there..

    cheers K

  8. #8
    Senior Member wwatson's Avatar
    Join Date
    Aug 2017
    Posts
    426
    Quote Originally Posted by KurtE View Post
    One of these? https://www.buydisplay.com/spi-1280x...ve-touch-panel

    If so you might take a look at our RA8876 driver that a few of us have been playing with:
    https://github.com/wwatson4506/Ra8876LiteTeensy

    Note: Currently you need to use the other branch of the library: https://github.com/wwatson4506/Ra887...sy-ER-TFTM0874
    I have an open Pull Request to that branch to hopefully make it compatible with the other RA8876 boards we are using (1024x600), hopefully when a few people try out my PR to make sure it still works for the display I think you have, we will get this PR pulled into the branch I mentioned and then that branch PRd into master...

    More details in the thread https://forum.pjrc.com/threads/58565...sy-T36-and-T40

    As for MISO pin. You have a couple of issues. Use a secondary SPI port like SPI1.
    With MOSI1=26, SCK1=27, MISO1 = (1, 39) Note pin 1 is default to use 39 SPI1.setMISO(39); THere are a few hardware CS pins, not really used on this device so can be any digital pin.

    My adapter board, I have the option to put in a buffer to make it tristate. But the one board I populated, I shorted this out as I only use this display to test, so did not matter that other SPI devices may not work with it.
    @KurtE - Sorry for this late reply. I did do the pull request. Tested all of the examples and came up with the results you and @mjs513 did. Everything works. The font examples I still have to understand. They randomly produce different results. Could be my display setup.
    I think I am parallel with your repository now.

    Thanks for all of you and @mjs513 for your hard work on this rewrite of the library

  9. #9
    Junior Member
    Join Date
    Aug 2020
    Posts
    2
    Quote Originally Posted by KurtE View Post
    One of these? https://www.buydisplay.com/spi-1280x...ve-touch-panel

    If so you might take a look at our RA8876 driver that a few of us have been playing with:
    https://github.com/wwatson4506/Ra8876LiteTeensy

    Note: Currently you need to use the other branch of the library: https://github.com/wwatson4506/Ra887...sy-ER-TFTM0874
    I have an open Pull Request to that branch to hopefully make it compatible with the other RA8876 boards we are using (1024x600), hopefully when a few people try out my PR to make sure it still works for the display I think you have, we will get this PR pulled into the branch I mentioned and then that branch PRd into master...

    More details in the thread https://forum.pjrc.com/threads/58565...sy-T36-and-T40

    As for MISO pin. You have a couple of issues. Use a secondary SPI port like SPI1.
    With MOSI1=26, SCK1=27, MISO1 = (1, 39) Note pin 1 is default to use 39 SPI1.setMISO(39); THere are a few hardware CS pins, not really used on this device so can be any digital pin.

    My adapter board, I have the option to put in a buffer to make it tristate. But the one board I populated, I shorted this out as I only use this display to test, so did not matter that other SPI devices may not work with it.
    Kurt, huge thanks for everything i really appreciate it all. i'm a newbie, just registered, and i'm learning so all your info, link and entire post is super helpful for me. i wanted to ask you if you don't mind asking questions in case something goes wrong or if i have any other additional questions. thanks.

  10. #10
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    You are welcome and welcome.

    And there are many of us up here on the forum, who try to help out as we can.

  11. #11
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Hi group,

    I noticed that the MAX31856 is not working on the SPI1 bus used MOSI1 pin 26, SCK1 pin 27, MISO1 pin 1 and CS1 pin 0, I need this pins because my RA8875 display is on SPI0.
    Is there a explanation why this will not work?
    Best regards,
    Johan

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,074
    Quote Originally Posted by pd0lew View Post
    Is there a explanation why this will not work?
    Yes, though "blind guess" would be a better phrase than "explanation" when we can't see your code or which library you're using or your wiring.

    So here's a few blind guesses

    1: The library might be hard-coded to only use SPI. In this case, all "SPI" inside the lib's code need to be edited to "SPI1".

    2: The library might support other SPI ports, but your code doesn't correctly configure SPI1.

    3: You may have a mistake or misunderstanding in connecting the wires. Misunderstanding are usually only solvable with photos.

    I did assume you're using some library to access the MAX31856, which is also a blind guess. If you actually copied code from a website or wrote it all yourself from scratch, take "library" to mean whatever code you're using for the MAX31856 communication.

    Really, I mostly hope you can see how giving no info about what you've actually done (eg, the "Forum Rule" at the top of every page) means we have to blind guess to try helping. We can help you so much better & faster when we can actually see what you're trying.

  13. #13
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    Quote Originally Posted by pd0lew View Post
    Hi group,

    I noticed that the MAX31856 is not working on the SPI1 bus used MOSI1 pin 26, SCK1 pin 27, MISO1 pin 1 and CS1 pin 0, I need this pins because my RA8875 display is on SPI0.
    Is there a explanation why this will not work?
    Best regards,
    Johan
    Dito, hard to help without more details. Like which teensy... But Assuming 4.1 by title of thread. Pin numbers should work for T4 or T4.1...

    This has been talked about in a couple of threads including: https://forum.pjrc.com/threads/66607...light=max31855

    As part of that other thread I added support to Adafruit library to specify a different SPI port, which I issued a PR which was integrated, and user on previous thread confirmed (I don't have these devices).
    I believe that the updated version is available through Arduino library manager, or you can update/install from their github:

    You should be able to create one like Adafruit_MAX31855(0, &SPI1)

  14. #14
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Hi all,

    I used here a Teensy 4.1 with a MAX31856 connected to SPI1 bus used MOSI1 pin 26, SCK1 pin 27, MISO1 pin 1 and CS1 pin 0.

    Also I did this as suggested by Kurt > Adafruit_MAX31855(0, &SPI1) and changed it to Adafruit_MAX31856(0, &SPI1)

    The error is "no matching function for call to 'Adafruit_MAX31856::Adafruit_MAX31856(int, SPIClass*)'
    Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(0,&SPI1);"


    For sure the wiring is good checked that several times, when the MAX is connected the SPI0 than this works, however I must use SPI0 for my RA8875 display.

    Best regards and thanks for the help.
    Johan

  15. #15
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    Yes it looks like Adafruit has not updated their AD31856 library...

    Would not be hard. Someone needs to make the same changes I made for AD31855 library, which is trivial.

    That is: change their header file:
    Code:
    #include <Adafruit_SPIDevice.h>
    
    /**************************************************************************/
    /*!
        @brief  Class that stores state and functions for interacting with MAX31856
    */
    /**************************************************************************/
    
    class Adafruit_MAX31856 {
    public:
      Adafruit_MAX31856(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso,
                        int8_t spi_clk);
      Adafruit_MAX31856(int8_t spi_cs);
    To setup the second constructor to allow optional SPI
    Code:
    #include <Adafruit_SPIDevice.h>
    
    /**************************************************************************/
    /*!
        @brief  Class that stores state and functions for interacting with MAX31856
    */
    /**************************************************************************/
    
    class Adafruit_MAX31856 {
    public:
      Adafruit_MAX31856(int8_t spi_cs, int8_t spi_mosi, int8_t spi_miso,
                        int8_t spi_clk);
      Adafruit_MAX31856(int8_t spi_cs, SPIClass *_spi = &SPI);
    Then change their implementation for the constructor to the cpp file:
    Code:
    /**************************************************************************/
    /*!
        @brief  Instantiate MAX31856 object and use hardware SPI
        @param  spi_cs Any pin for SPI Chip Select
    */
    /**************************************************************************/
    Adafruit_MAX31856::Adafruit_MAX31856(int8_t spi_cs)
        : spi_dev(spi_cs, 1000000, SPI_BITORDER_MSBFIRST, SPI_MODE1) {}
    To:
    Code:
    /**************************************************************************/
    /*!
        @brief  Instantiate MAX31856 object and use hardware SPI
        @param  spi_cs Any pin for SPI Chip Select
    */
    /**************************************************************************/
    Adafruit_MAX31856::Adafruit_MAX31856(int8_t spi_cs, SPIClass *_spi)
        : spi_dev(spi_cs, 1000000, SPI_BITORDER_MSBFIRST, SPI_MODE1, _spi) {}
    And then hopefully test it out and make sure it works and then issue a Pull Request back to Adafruit.

  16. #16
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Hi Kurt, group,

    Made the changes in the both files and YES now it works.

    Thanks a lot for helping this was really a quick solution!

    Best,
    Johan
    Code:
    // This example demonstrates continuous conversion mode using the
    
    #include <Adafruit_MAX31856.h>
    
    Adafruit_MAX31856 maxthermo = Adafruit_MAX31856(5, &SPI1);
    
    void setup() {
      Serial.begin(115200);
      while (!Serial) delay(10);
      Serial.println("MAX31856 thermocouple test");
    
        if (!maxthermo.begin()) {
        Serial.println("Could not initialize thermocouple.");
        while (1) delay(10);
      }
    
      maxthermo.setThermocoupleType(MAX31856_TCTYPE_K);
    
      Serial.print("Thermocouple type: ");
      switch (maxthermo.getThermocoupleType() ) {
        case MAX31856_TCTYPE_B: Serial.println("B Type"); break;
        case MAX31856_TCTYPE_E: Serial.println("E Type"); break;
        case MAX31856_TCTYPE_J: Serial.println("J Type"); break;
        case MAX31856_TCTYPE_K: Serial.println("K Type"); break;
        case MAX31856_TCTYPE_N: Serial.println("N Type"); break;
        case MAX31856_TCTYPE_R: Serial.println("R Type"); break;
        case MAX31856_TCTYPE_S: Serial.println("S Type"); break;
        case MAX31856_TCTYPE_T: Serial.println("T Type"); break;
        case MAX31856_VMODE_G8: Serial.println("Voltage x8 Gain mode"); break;
        case MAX31856_VMODE_G32: Serial.println("Voltage x8 Gain mode"); break;
        default: Serial.println("Unknown"); break;
      }
    
      maxthermo.setConversionMode(MAX31856_CONTINUOUS);
    }
    
    void loop() {
     
     
      Serial.println(maxthermo.readThermocoupleTemperature());
    }

  17. #17
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    Quick FYI - I have issued PR to Adafruit, will see how well this one goes through.
    https://github.com/adafruit/Adafruit_MAX31856/pull/28

  18. #18
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Hi Kurt,
    Thanks for that!

    I have the same problem for a display with I2C bus on a Teensy 4.1, while on SCL0 and SDA0 this works out of the box with the scanner and the device is found. On SCL1 and SDA1 no device found.


    Code:
    // --------------------------------------
    // i2c_scanner
    // http://playground.arduino.cc/Main/I2cScanner
    //
    // Version 1
    //    This program (or code that looks like it)
    //    can be found in many places.
    //    For example on the Arduino.cc forum.
    //    The original author is not know.
    // Version 2, Juni 2012, Using Arduino 1.0.1
    //     Adapted to be as simple as possible by Arduino.cc user Krodal
    // Version 3, Feb 26  2013
    //    V3 by louarnold
    // Version 4, March 3, 2013, Using Arduino 1.0.3
    //    by Arduino.cc user Krodal.
    //    Changes by louarnold removed.
    //    Scanning addresses changed from 0...127 to 1...119,
    //    according to the i2c scanner by Nick Gammon
    //    http://www.gammon.com.au/forum/?id=10896
    // Version 5, March 28, 2013
    //    As version 4, but address scans now to 127.
    //    A sensor seems to use address 120.
    // Version 6, November 27, 2015.
    //    Added waiting for the Leonardo serial communication.
    //
    //
    // This sketch tests the standard 7-bit addresses
    // Devices with higher bit address might not be seen properly.
    //
    
    #include <Wire.h>
    
    
    void setup() {
      // uncomment these to use alternate pins
      //Wire1.setSCL(16);
      //Wire1.setSDA(17);
      Wire1.begin();
      Serial.begin(9600);
      while (!Serial);        // Leonardo: wait for serial monitor
      Serial.println(F("\nI2C Scanner"));
    }
    
    
    void loop() {
      byte error, address;
      int nDevices;
    
      Serial.println(F("Scanning..."));
    
      nDevices = 0;
      for (address = 1; address < 127; address++) {
        // The i2c_scanner uses the return value of
        // the Write.endTransmisstion to see if
        // a device did acknowledge to the address.
        Wire.beginTransmission(address);
        error = Wire.endTransmission();
    
        if (error == 0) {
          Serial.print(F("Device found at address 0x"));
          if (address < 16) {
            Serial.print("0");
          }
          Serial.print(address,HEX);
          Serial.print("  (");
          printKnownChips(address);
          Serial.println(")");
    
          nDevices++;
        } else if (error==4) {
          Serial.print(F("Unknown error at address 0x"));
          if (address < 16) {
            Serial.print("0");
          }
          Serial.println(address,HEX);
        }
      }
      if (nDevices == 0) {
        Serial.println(F("No I2C devices found\n"));
      } else {
        Serial.println(F("done\n"));
      }
      delay(5000);           // wait 5 seconds for next scan
    }
    
    
    void printKnownChips(byte address)
    {
      // Is this list missing part numbers for chips you use?
      // Please suggest additions here:
      // https://github.com/PaulStoffregen/Wire/issues/new
      switch (address) {
        case 0x00: Serial.print(F("AS3935")); break;
        case 0x01: Serial.print(F("AS3935")); break;
        case 0x02: Serial.print(F("AS3935")); break;
        case 0x03: Serial.print(F("AS3935")); break;
        case 0x0A: Serial.print(F("SGTL5000")); break; // MCLK required
        case 0x0B: Serial.print(F("SMBusBattery?")); break;
        case 0x0C: Serial.print(F("AK8963")); break;
        case 0x10: Serial.print(F("CS4272")); break;
        case 0x11: Serial.print(F("Si4713")); break;
        case 0x13: Serial.print(F("VCNL4000,AK4558")); break;
        case 0x18: Serial.print(F("LIS331DLH")); break;
        case 0x19: Serial.print(F("LSM303,LIS331DLH")); break;
        case 0x1A: Serial.print(F("WM8731")); break;
        case 0x1C: Serial.print(F("LIS3MDL")); break;
        case 0x1D: Serial.print(F("LSM303D,LSM9DS0,ADXL345,MMA7455L,LSM9DS1,LIS3DSH")); break;
        case 0x1E: Serial.print(F("LSM303D,HMC5883L,FXOS8700,LIS3DSH")); break;
        case 0x20: Serial.print(F("MCP23017,MCP23008,PCF8574,FXAS21002,SoilMoisture")); break;
        case 0x21: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x22: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x23: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x24: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x25: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x26: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x27: Serial.print(F("MCP23017,MCP23008,PCF8574,LCD16x2,DigoleDisplay")); break;
        case 0x28: Serial.print(F("BNO055,EM7180,CAP1188")); break;
        case 0x29: Serial.print(F("TSL2561,VL6180,TSL2561,TSL2591,BNO055,CAP1188")); break;
        case 0x2A: Serial.print(F("SGTL5000,CAP1188")); break;
        case 0x2B: Serial.print(F("CAP1188")); break;
        case 0x2C: Serial.print(F("MCP44XX ePot")); break;
        case 0x2D: Serial.print(F("MCP44XX ePot")); break;
        case 0x2E: Serial.print(F("MCP44XX ePot")); break;
        case 0x2F: Serial.print(F("MCP44XX ePot")); break;
        case 0x30: Serial.print(F("Si7210")); break;
        case 0x31: Serial.print(F("Si7210")); break;
        case 0x32: Serial.print(F("Si7210")); break;
        case 0x33: Serial.print(F("MAX11614,MAX11615,Si7210")); break;
        case 0x34: Serial.print(F("MAX11612,MAX11613")); break;
        case 0x35: Serial.print(F("MAX11616,MAX11617")); break;
        case 0x38: Serial.print(F("RA8875,FT6206,MAX98390")); break;
        case 0x39: Serial.print(F("TSL2561, APDS9960")); break;
        case 0x3C: Serial.print(F("SSD1306,DigisparkOLED")); break;
        case 0x3D: Serial.print(F("SSD1306")); break;
        case 0x40: Serial.print(F("PCA9685,Si7021,MS8607")); break;
        case 0x41: Serial.print(F("STMPE610,PCA9685")); break;
        case 0x42: Serial.print(F("PCA9685")); break;
        case 0x43: Serial.print(F("PCA9685")); break;
        case 0x44: Serial.print(F("PCA9685, SHT3X")); break;
        case 0x45: Serial.print(F("PCA9685, SHT3X")); break;
        case 0x46: Serial.print(F("PCA9685")); break;
        case 0x47: Serial.print(F("PCA9685")); break;
        case 0x48: Serial.print(F("ADS1115,PN532,TMP102,LM75,PCF8591")); break;
        case 0x49: Serial.print(F("ADS1115,TSL2561,PCF8591")); break;
        case 0x4A: Serial.print(F("ADS1115,Qwiic Keypad")); break;
        case 0x4B: Serial.print(F("ADS1115,TMP102,BNO080,Qwiic Keypad")); break;
        case 0x50: Serial.print(F("EEPROM,FRAM")); break;
        case 0x51: Serial.print(F("EEPROM")); break;
        case 0x52: Serial.print(F("Nunchuk,EEPROM")); break;
        case 0x53: Serial.print(F("ADXL345,EEPROM")); break;
        case 0x54: Serial.print(F("EEPROM")); break;
        case 0x55: Serial.print(F("EEPROM")); break;
        case 0x56: Serial.print(F("EEPROM")); break;
        case 0x57: Serial.print(F("EEPROM")); break;
        case 0x58: Serial.print(F("TPA2016,MAX21100")); break;
        case 0x5A: Serial.print(F("MPR121")); break;
        case 0x60: Serial.print(F("MPL3115,MCP4725,MCP4728,TEA5767,Si5351")); break;
        case 0x61: Serial.print(F("MCP4725,AtlasEzoDO")); break;
        case 0x62: Serial.print(F("LidarLite,MCP4725,AtlasEzoORP")); break;
        case 0x63: Serial.print(F("MCP4725,AtlasEzoPH")); break;
        case 0x64: Serial.print(F("AtlasEzoEC")); break;
        case 0x66: Serial.print(F("AtlasEzoRTD")); break;
        case 0x68: Serial.print(F("DS1307,DS3231,MPU6050,MPU9050,MPU9250,ITG3200,ITG3701,LSM9DS0,L3G4200D")); break;
        case 0x69: Serial.print(F("MPU6050,MPU9050,MPU9250,ITG3701,L3G4200D")); break;
        case 0x6A: Serial.print(F("LSM9DS1")); break;
        case 0x6B: Serial.print(F("LSM9DS0")); break;
        case 0x6F: Serial.print(F("Qwiic Button")); break;
        case 0x70: Serial.print(F("HT16K33")); break;
        case 0x71: Serial.print(F("SFE7SEG,HT16K33")); break;
        case 0x72: Serial.print(F("HT16K33")); break;
        case 0x73: Serial.print(F("HT16K33")); break;
        case 0x76: Serial.print(F("MS5607,MS5611,MS5637,BMP280")); break;
        case 0x77: Serial.print(F("BMP085,BMA180,BMP280,MS5611")); break;
        case 0x7C: Serial.print(F("FRAM_ID")); break;
        default: Serial.print(F("unknown chip"));
      }
    }
    Best regards,
    Johan

  19. #19
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    Different hardware Wire versus SPI and yes lots of libraries do not support specifying which bus.

    In your above case not really using library... For the scanner there if you wish to use that code just change everywhere that uses the Wire object to instead use the Wire1 object
    Like loop:
    Code:
    void loop() {
      byte error, address;
      int nDevices;
    
      Serial.println(F("Scanning..."));
    
      nDevices = 0;
      for (address = 1; address < 127; address++) {
        // The i2c_scanner uses the return value of
        // the Write.endTransmisstion to see if
        // a device did acknowledge to the address.
        Wire1.beginTransmission(address);
        error = Wire1.endTransmission();
    
        if (error == 0) {
          Serial.print(F("Device found at address 0x"));
          if (address < 16) {
            Serial.print("0");
          }
          Serial.print(address,HEX);
          Serial.print("  (");
          printKnownChips(address);
          Serial.println(")");
    
          nDevices++;
        } else if (error==4) {
          Serial.print(F("Unknown error at address 0x"));
          if (address < 16) {
            Serial.print("0");
          }
          Serial.println(address,HEX);
        }
      }
      if (nDevices == 0) {
        Serial.println(F("No I2C devices found\n"));
      } else {
        Serial.println(F("done\n"));
      }
      delay(5000);           // wait 5 seconds for next scan
    }

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,074
    Quote Originally Posted by pd0lew View Post
    On SCL1 and SDA1 no device found.
    Looks like you changed Wire to Wire1 only in setup().

    You also need to edit these lines in loop()

    Code:
        Wire.beginTransmission(address);
        error = Wire.endTransmission();

  21. #21
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Hi group,

    The Teensy 4.1 second I2C SDA1/SCL1 bus is definitely not working , I connected several devices but nothing, however all the devices
    working on the first SDA0/SCL0.

    Did anyone used the second I2C bus on a Teensy 4.1, on a Teensy 4.0 both are working perfectly.


    [CODE

    #include <Wire.h>


    void setup() {
    // uncomment these to use alternate pins
    //Wire1.setSCL(16);
    //Wire1.setSDA(17);
    Wire1.begin();
    Serial.begin(9600);
    while (!Serial); // Leonardo: wait for serial monitor
    Serial.println(F("\nI2C Scanner"));
    }


    void loop() {
    byte error, address;
    int nDevices;

    Serial.println(F("Scanning..."));

    nDevices = 0;
    for (address = 1; address < 127; address++) {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire1.beginTransmission(address);
    error = Wire1.endTransmission();

    if (error == 0) {
    Serial.print(F("Device found at address 0x"));
    if (address < 16) {
    Serial.print("0");
    }
    Serial.print(address,HEX);
    Serial.print(" (");
    printKnownChips(address);
    Serial.println(")");

    nDevices++;
    } else if (error==4) {
    Serial.print(F("Unknown error at address 0x"));
    if (address < 16) {
    Serial.print("0");
    }
    Serial.println(address,HEX);
    }
    }
    if (nDevices == 0) {
    Serial.println(F("No I2C devices found\n"));
    } else {
    Serial.println(F("done\n"));
    }
    delay(5000); // wait 5 seconds for next scan
    }][/CODE]

  22. #22
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    Wire1 works just fine on T4.1... Here is a test setup that Paul setup earlier, where we can choose several devices and which Wire buss they are on.
    Click image for larger version. 

Name:	IMG_1359.jpg 
Views:	10 
Size:	117.5 KB 
ID:	24383

    Here is a Wire scanner program version that I have, that does all three busses.
    Code:
    // --------------------------------------
    // i2c_scanner
    // http://playground.arduino.cc/Main/I2cScanner
    //
    // Version 1
    //    This program (or code that looks like it)
    //    can be found in many places.
    //    For example on the Arduino.cc forum.
    //    The original author is not know.
    // Version 2, Juni 2012, Using Arduino 1.0.1
    //     Adapted to be as simple as possible by Arduino.cc user Krodal
    // Version 3, Feb 26  2013
    //    V3 by louarnold
    // Version 4, March 3, 2013, Using Arduino 1.0.3
    //    by Arduino.cc user Krodal.
    //    Changes by louarnold removed.
    //    Scanning addresses changed from 0...127 to 1...119,
    //    according to the i2c scanner by Nick Gammon
    //    http://www.gammon.com.au/forum/?id=10896
    // Version 5, March 28, 2013
    //    As version 4, but address scans now to 127.
    //    A sensor seems to use address 120.
    // Version 6, November 27, 2015.
    //    Added waiting for the Leonardo serial communication.
    //
    //
    // This sketch tests the standard 7-bit addresses
    // Devices with higher bit address might not be seen properly.
    //
    
    #include <Wire.h>
    
    // BUGBUG::Should put this in WireIMXRT.h
    #if defined(__IMXRT1062__)
    #define WIRE_IMPLEMENT_WIRE
    #define WIRE_IMPLEMENT_WIRE1
    #define WIRE_IMPLEMENT_WIRE2
    #endif
    typedef struct {
      TwoWire *_wire;
      const char * wire_name;
      IMXRT_LPI2C_t * const port;
    } wire_list_t;
    
    wire_list_t wireList[] = {
      {&Wire, "Wire", &IMXRT_LPI2C1}
    #if defined(WIRE_IMPLEMENT_WIRE1)
      , {&Wire1, "Wire1", &IMXRT_LPI2C3}
    #endif  
    #if defined(WIRE_IMPLEMENT_WIRE2)
      , {&Wire2, "Wire2", &IMXRT_LPI2C4}
    #endif
    #if defined(WIRE_IMPLEMENT_WIRE3)
      , {&Wire3, "Wire3"}
    #endif
    };
    const uint8_t wirelist_count = sizeof(wireList) / sizeof(wireList[0]);
    
    
    void setup() {
      // uncomment these to use alternate pins
      //Wire.setSCL(16);
      //Wire.setSDA(17);
      for (uint8_t wirelist_index = 0; wirelist_index < wirelist_count; wirelist_index++) {
        wireList[wirelist_index]._wire->begin();
      }
      Serial.begin(9600);
      while (!Serial);        // Leonardo: wait for serial monitor
      Serial.println(F("\nI2C Scanner"));
    }
    
    
    void loop() {
      byte error, address;
      int nDevices;
    
      for (uint8_t wirelist_index = 0; wirelist_index < wirelist_count; wirelist_index++) {
        IMXRT_LPI2C_t * const port = wireList[wirelist_index].port;
        Serial.print(F("Scanning("));
        Serial.print(wireList[wirelist_index].wire_name);
        Serial.println(F(")..."));
        nDevices = 0;
        for (address = 1; address < 127; address++) {
          // The i2c_scanner uses the return value of
          // the Write.endTransmisstion to see if
          // a device did acknowledge to the address.
          wireList[wirelist_index]._wire->beginTransmission(address);
          error = wireList[wirelist_index]._wire->endTransmission();
    
          if (error == 0) {
            Serial.print(F("Device found at address 0x"));
            if (address < 16) {
              Serial.print("0");
            }
            Serial.print(address, HEX);
            Serial.print("  (");
            printKnownChips(address);
            Serial.println(")");
    
            nDevices++;
          } else if (error == 4) {
            Serial.print(F("Unknown error at address 0x"));
            if (address < 16) {
              Serial.print("0");
            }
            Serial.print(address, HEX);
            Serial.printf("MCR:%x MSR:%x, MIER:%x MDER:%x MCFGR0:%x MDMR:%x MCCR0:%x\n",
              port->MCR, port->MSR, port->MIER, port->MDER, port->MCFGR0, port->MDMR, port->MCCR0);
          }
        }
        if (nDevices == 0) {
          Serial.println(F("No I2C devices found\n"));
        } else {
          Serial.println(F("done\n"));
        }
      }
      delay(5000);           // wait 5 seconds for next scan
    }
    
    
    void printKnownChips(byte address)
    {
      // Is this list missing part numbers for chips you use?
      // Please suggest additions here:
      // https://github.com/PaulStoffregen/Wire/issues/new
      switch (address) {
        case 0x00: Serial.print(F("AS3935")); break;
        case 0x01: Serial.print(F("AS3935")); break;
        case 0x02: Serial.print(F("AS3935")); break;
        case 0x03: Serial.print(F("AS3935")); break;
        case 0x0A: Serial.print(F("SGTL5000")); break; // MCLK required
        case 0x0B: Serial.print(F("SMBusBattery?")); break;
        case 0x0C: Serial.print(F("AK8963")); break;
        case 0x10: Serial.print(F("CS4272")); break;
        case 0x11: Serial.print(F("Si4713")); break;
        case 0x13: Serial.print(F("VCNL4000,AK4558")); break;
        case 0x18: Serial.print(F("LIS331DLH")); break;
        case 0x19: Serial.print(F("LSM303,LIS331DLH")); break;
        case 0x1A: Serial.print(F("WM8731")); break;
        case 0x1C: Serial.print(F("LIS3MDL")); break;
        case 0x1D: Serial.print(F("LSM303D,LSM9DS0,ADXL345,MMA7455L,LSM9DS1,LIS3DSH")); break;
        case 0x1E: Serial.print(F("LSM303D,HMC5883L,FXOS8700,LIS3DSH")); break;
        case 0x20: Serial.print(F("MCP23017,MCP23008,PCF8574,FXAS21002,SoilMoisture")); break;
        case 0x21: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x22: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x23: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x24: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x25: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x26: Serial.print(F("MCP23017,MCP23008,PCF8574")); break;
        case 0x27: Serial.print(F("MCP23017,MCP23008,PCF8574,LCD16x2,DigoleDisplay")); break;
        case 0x28: Serial.print(F("BNO055,EM7180,CAP1188")); break;
        case 0x29: Serial.print(F("TSL2561,VL6180,TSL2561,TSL2591,BNO055,CAP1188")); break;
        case 0x2A: Serial.print(F("SGTL5000,CAP1188")); break;
        case 0x2B: Serial.print(F("CAP1188")); break;
        case 0x2C: Serial.print(F("MCP44XX ePot")); break;
        case 0x2D: Serial.print(F("MCP44XX ePot")); break;
        case 0x2E: Serial.print(F("MCP44XX ePot")); break;
        case 0x2F: Serial.print(F("MCP44XX ePot")); break;
        case 0x33: Serial.print(F("MAX11614,MAX11615")); break;
        case 0x34: Serial.print(F("MAX11612,MAX11613")); break;
        case 0x35: Serial.print(F("MAX11616,MAX11617")); break;
        case 0x38: Serial.print(F("RA8875,FT6206,MAX98390")); break;
        case 0x39: Serial.print(F("TSL2561, APDS9960")); break;
        case 0x3C: Serial.print(F("SSD1306,DigisparkOLED")); break;
        case 0x3D: Serial.print(F("SSD1306")); break;
        case 0x40: Serial.print(F("PCA9685,Si7021")); break;
        case 0x41: Serial.print(F("STMPE610,PCA9685")); break;
        case 0x42: Serial.print(F("PCA9685")); break;
        case 0x43: Serial.print(F("PCA9685")); break;
        case 0x44: Serial.print(F("PCA9685, SHT3X")); break;
        case 0x45: Serial.print(F("PCA9685, SHT3X")); break;
        case 0x46: Serial.print(F("PCA9685")); break;
        case 0x47: Serial.print(F("PCA9685")); break;
        case 0x48: Serial.print(F("ADS1115,PN532,TMP102,LM75,PCF8591")); break;
        case 0x49: Serial.print(F("ADS1115,TSL2561,PCF8591")); break;
        case 0x4A: Serial.print(F("ADS1115")); break;
        case 0x4B: Serial.print(F("ADS1115,TMP102,BNO080")); break;
        case 0x50: Serial.print(F("EEPROM,FRAM")); break;
        case 0x51: Serial.print(F("EEPROM")); break;
        case 0x52: Serial.print(F("Nunchuk,EEPROM")); break;
        case 0x53: Serial.print(F("ADXL345,EEPROM")); break;
        case 0x54: Serial.print(F("EEPROM")); break;
        case 0x55: Serial.print(F("EEPROM")); break;
        case 0x56: Serial.print(F("EEPROM")); break;
        case 0x57: Serial.print(F("EEPROM")); break;
        case 0x58: Serial.print(F("TPA2016,MAX21100")); break;
        case 0x5A: Serial.print(F("MPR121")); break;
        case 0x60: Serial.print(F("MPL3115,MCP4725,MCP4728,TEA5767,Si5351")); break;
        case 0x61: Serial.print(F("MCP4725,AtlasEzoDO")); break;
        case 0x62: Serial.print(F("LidarLite,MCP4725,AtlasEzoORP")); break;
        case 0x63: Serial.print(F("MCP4725,AtlasEzoPH")); break;
        case 0x64: Serial.print(F("AtlasEzoEC")); break;
        case 0x66: Serial.print(F("AtlasEzoRTD")); break;
        case 0x68: Serial.print(F("DS1307,DS3231,MPU6050,MPU9050,MPU9250,ITG3200,ITG3701,LSM9DS0,L3G4200D")); break;
        case 0x69: Serial.print(F("MPU6050,MPU9050,MPU9250,ITG3701,L3G4200D")); break;
        case 0x6A: Serial.print(F("LSM9DS1")); break;
        case 0x6B: Serial.print(F("LSM9DS0")); break;
        case 0x70: Serial.print(F("HT16K33")); break;
        case 0x71: Serial.print(F("SFE7SEG,HT16K33")); break;
        case 0x72: Serial.print(F("HT16K33")); break;
        case 0x73: Serial.print(F("HT16K33")); break;
        case 0x76: Serial.print(F("MS5607,MS5611,MS5637,BMP280")); break;
        case 0x77: Serial.print(F("BMP085,BMA180,BMP280,MS5611")); break;
        case 0x7C: Serial.print(F("FRAM_ID")); break;
        default: Serial.print(F("unknown chip"));
      }
    }
    Here is output:
    Code:
    I2C Scanner
    Scanning(Wire)...
    Device found at address 0x29  (TSL2561,VL6180,TSL2561,TSL2591,BNO055,CAP1188)
    Device found at address 0x4B  (ADS1115,TMP102,BNO080)
    Device found at address 0x62  (LidarLite,MCP4725,AtlasEzoORP)
    Device found at address 0x68  (DS1307,DS3231,MPU6050,MPU9050,MPU9250,ITG3200,ITG3701,LSM9DS0,L3G4200D)
    done
    
    Scanning(Wire1)...
    Device found at address 0x3C  (SSD1306,DigisparkOLED)
    Device found at address 0x50  (EEPROM,FRAM)
    Device found at address 0x7C  (FRAM_ID)
    done
    
    Scanning(Wire2)...
    Device found at address 0x09  (unknown chip)
    done

  23. #23
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,279
    Remember the pins are in swapped order.

  24. #24
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,987
    Quote Originally Posted by Frank B View Post
    Remember the pins are in swapped order.
    Good point. I was also going to suggest that he double check his wiring, plus not knowing which devices he has, check to make there is some Pull UP resistors. on the pins.

    And maybe post photo of setup. Maybe the pins are not soldered or shorted or ...

  25. #25
    Senior Member
    Join Date
    May 2017
    Location
    Netherlands
    Posts
    139
    Hi Kurt, group,

    Tested the T4.1 with the scanner and Wire is ok, Wire1 not found, Wire2 is ok it seems that the T4.1 has a defect. I will order a new one.

    Thanks for helping!
    Best regards,
    Johan

Posting Permissions

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