Need basic help using TCA9548A Multiplexer and teensy 3.6

Status
Not open for further replies.

rotabox

Well-known member
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
 
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.
 
in setup() try adding Wire1.begin();
thats what im get in scan.
thats is normal?
Screen Shot 2019-03-21 at 2.37.44 PM.jpg
 
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
 
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?
 
@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
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
 
@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.
 

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

Screen Shot 2019-03-22 at 2.19.51 PM.jpg
 
Status
Not open for further replies.
Back
Top