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

Thread: Need basic help using TCA9548A Multiplexer and teensy 3.6

  1. #1

    Need basic help using TCA9548A Multiplexer and teensy 3.6

    hello
    my adafruit TCA9548A arrived and i connected it to SDA1 SCL1 pins 37,38 on teensy.
    i run i2c scanner and i find the address 0x70 under WIRE1.
    im trying to run 8 oled screen 128x64 connected to the TCA9548A
    all the pullups working well and i measure all SDA SCL pins and i got 3.3 on all of them so the schem is ok.
    this is code to test im trying to run i change all the WIRE. to WIRE1
    and i add the u8glib.begin() in the loop but its stiil not operate any of my screens.
    please help me to figure out what im doing wrong.

    the code im using:
    Code:
    #include <Wire.h>
    #include <U8glib.h>
    #define TCAADDR 0x70 // TCA9548A Encoder address
    
    char tmp_string[8];  //Temp string to convert numeric values to string before print to OLED display
    int n=0;             // Loop counter, to verify that data is updated at the display
    uint8_t t=0;         // Port selection (0...7)
    
    U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_FAST);  // Fast I2C / TWI
     
    void tcaselect(uint8_t i) {
      if (i > 7) return;
      Wire1.beginTransmission(TCAADDR);
      Wire1.write(1 << i);
      Wire1.endTransmission(); 
    }
    
    void setup(){
      DisplayInit();
    }
    
    void draw(void) {
    
             u8g.setFont(u8g_font_ncenB10);
             u8g.drawStr(0, 13, "Port =");
             itoa(t, tmp_string, 10);  
             u8g.drawStr(50, 13, tmp_string);
            
             u8g.drawStr(0, 50, "n =");
             itoa(n, tmp_string, 10);  
             u8g.setFont(u8g_font_ncenB18);
             u8g.drawStr(25, 50, tmp_string);
    }
    
    void DisplayInit(){
        for (t=0; t<7; t++) {
          tcaselect(t);
                    u8g.firstPage();  
                    do {
                        u8g.begin();  // Initialize display
                       } while( u8g.nextPage() );
            }      
    }
    
    void loop(){
    
        for (t=0; t<7; t++) {
          tcaselect(t);
       u8g.begin();
      // picture loop
      u8g.firstPage();  
      do {
        draw();
      } while( u8g.nextPage() );
     delay(50);
            }      
    
    n=n+1;
    delay(500);
    }
    tnx
    rota

  2. #2
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,083
    in setup() try adding Wire1.begin();

  3. #3
    i added Wire1.begin(); in setup but its still not start my screens
    im trying to change the using u8g2 lib insted and alsoo display commend but its not working.

  4. #4
    Quote Originally Posted by manitou View Post
    in setup() try adding Wire1.begin();
    thats what im get in scan.
    thats is normal?
    Click image for larger version. 

Name:	Screen Shot 2019-03-21 at 2.37.44 PM.jpg 
Views:	20 
Size:	127.8 KB 
ID:	16198

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,306
    Have you done anything to cause the u8g to use Wire1 rather than ordinary Wire?

  6. #6
    Quote Originally Posted by PaulStoffregen View Post
    Have you done anything to cause the u8g to use Wire1 rather than ordinary Wire?
    I guess I'm not
    How should i cause the u8g or u8g2 to use wire1?

  7. #7
    Quote Originally Posted by PaulStoffregen View Post
    Have you done anything to cause the u8g to use Wire1 rather than ordinary Wire?
    hy paul
    i didnt understand .
    i read over the net and i found here [URL="https://github.com/olikraus/u8g2/issues/244[/URL]
    that i need to add _2ND_HW_I2C i tryed that but its not send nothing screens.
    i geuss im stiil doing something wrong and im really not understand what should i do to make U8g use wire1
    please help me

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,306
    Sorry, I know almost nothing about that library. I can't help.

    Maybe your best path is to simply use Wire instead of Wire1? Yeah, I know changing the wires you've already connected may be difficult. But ask yourself, is that easier than figuring out how to edit that library?

  9. #9
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,456
    @rotabox: Why donít you systematically study the source code of that library until you really understand every single line? Afterwards, it will most probably be very easy to do the needed modifications. The other question is, why must it absolutely be WIRE1? Did you try to connect your stuff on pins 18/19 and using the normal WIRE object with default settings, instead?

  10. #10
    tnx for your replay
    that project is assembly on pcb . Wire0 is in use all ready connected to another teensy in slave mode.
    i wanna use 2 different i2c buses in the same time. now i understand that i need to edit the lib to get it working that a bit beheind my skiils.
    maybe ill add it to the wire0 in parallel like you said thats the best easy way. but then i have EXT pullup resistor on wire0 all ready should i just cut the internal pullups on the TCA module and connect it to Wire0 in parallel?
    the 2 (2k2)external resistors r ok for SDA SCL that carry 2 modules and sharing same pullups?
    im using

  11. #11
    Quote Originally Posted by Theremingenieur View Post
    @rotabox: Why don’t you systematically study the source code of that library until you really understand every single line? Afterwards, it will most probably be very easy to do the needed modifications. The other question is, why must it absolutely be WIRE1? Did you try to connect your stuff on pins 18/19 and using the normal WIRE object with default settings, instead?
    tnx for your replay Theremingenieur
    like i told to paul i allready pland and create pcb i didnt know that gonna be big isuue to just send 1 more i2c bus to control a device.
    i new in micro controlers and teensy world and really new in the code area.
    im also runing 1mh in the Wire0 now and i know that TCA work max in 400kh. i geuss that sould be also a problem.

  12. #12
    here is the pcb
    Click image for larger version. 

Name:	Screen Shot 2019-03-21 at 10.43.59 PM.jpg 
Views:	24 
Size:	114.6 KB 
ID:	16206

  13. #13
    Quote Originally Posted by rotabox View Post
    here is the pcb
    Click image for larger version. 

Name:	Screen Shot 2019-03-21 at 10.43.59 PM.jpg 
Views:	24 
Size:	114.6 KB 
ID:	16206
    update:
    i used the adafruit 1306 oled i2s example .
    i added in setup void
    Code:
    display.begin(SSD1306_SWITCHCAPVCC, 0x70);
    and i aaded that address in under tcaselect(i);
    Code:
    display.begin(SSD1306_SWITCHCAPVCC, 0x3c);
    now im struggling to send strings (names) to screen from usb midi sysex masseges but its seems that adafruit gfx lib not so fraindly to strings like u8g2.

    maney thanks guys for giving me some direction

    Click image for larger version. 

Name:	Screen Shot 2019-03-22 at 2.19.51 PM.jpg 
Views:	14 
Size:	81.9 KB 
ID:	16211

Posting Permissions

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