This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TCA9548A: TCA9548A

Part Number: TCA9548A

I am working on an iI2C Scanner for the TCA9548A.  I can see the I2C addresses that are on the bus but cannot see anything attached to the TCA.  I have used this chip with an Arduino Mega and works as intended.  Here is the output from the Arduino:

TCAScanner is ready
TCA Port #0
TCA Port #1
Found I2C 0x1E
TCA Port #2
TCA Port #3
Found I2C 0x1E
TCA Port #4
TCA Port #5
TCA Port #6
TCA Port #7

I can see that there is a device on the Port of the TCA.

Here are the results from the code below.

TCA Port #0ACK addr: E0
Found: 1

TCA Port #1ACK addr: E0
Found: 1

TCA Port #2ACK addr: E0
Found: 1

TCA Port #3ACK addr: E0
Found: 1

TCA Port #4ACK addr: E0
Found: 1

TCA Port #5ACK addr: E0
Found: 1

TCA Port #6ACK addr: E0
Found: 1

TCA Port #7ACK addr: E0
Found: 1

I am trying to duplicate this on the PIC16F877A and the CCS PCWH Complier Version 5.115.

Here is the code.  

#include <16F877A.h>
#device ADC=16
#device ICD=TRUE

//#fuses HS
#FUSES NOWDT //No Watch Dog Timer
//#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOPUT //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O

#use delay(crystal=20mHz)
#use rs232(baud=9600,parity=N,UART1,bits=8,stream=RS232,errors)
#use i2c(Master, slow,i2c1,force_hw)

unsigned int8 I2C_Address;
unsigned int8 status;
unsigned int8 Device_Count = 0;
int8 Channel;


#define TCAaddr 0xEE //for A0,A1,A2=0b111
const int8 bus_array[8]={1,2,4,8,16,32,64,128};

void select_bus(int bus)
{
if (bus > 7 )
return; //trap illegal bus numbers
I2C_start();
I2C_write(TCAaddr);
I2C_write(bus_array[bus]); //select specified bus number
I2C_stop(); //I2C bus now routes to BUS number
}

//Then with the ADXL wired as described above, simply call
// select_bus(0);
//And the ADXL will now be connected to the I2C bus with level
//translation.
//You then write to the ADXL as normal.


int8 get_ack_status(int8 address)
{
int8 ack;

i2c_start();
delay_us(20);
ack = i2c_write(address); // Status = 0 if got an ACK
i2c_stop();
delay_us(20);
if(ack == 0)
return(TRUE);
else
return(FALSE);
}

void Get_I2C_Addresses(void){
// Try all slave addresses from 0x10 to 0xEF.
// See if we get a response from any slaves
// that may be on the i2c bus.
// for(I2C_Address = 0x10; I2C_Address < 0xF0; I2C_Address+=2) // original
for(I2C_Address = 0x10; I2C_Address < 0xE8; I2C_Address+=2) // trimmed down to avoid scanning mux address, just in case
{
status = get_ack_status(I2C_Address);
if(status == TRUE)
{
printf("ACK addr: %X\n\r", I2C_Address);
Device_Count++;
delay_ms(100);
}
}

if(Device_Count == 0){
printf("Nothing Found\n\r");
delay_cycles(1);
}
else{
printf("Found: %u\n\r", Device_Count);
delay_cycles(1);
}
}


//=================================
void main(){

output_float(PIN_B0);
output_float(PIN_B1);


for(Channel = 0; Channel < 8; Channel++)
{ // loop through channels

select_bus(bus_array[Channel]);
printf("\n\rTCA Port #%d",Channel);

Device_Count = 0;

Get_I2C_Addresses(); //I2C scanner

}
while(1);
}

Do I need a driver for this?

  • Hi Ed,

    I am not familiar with the PIC16F877A. Are these problems occurring with the PIC16 or are you using the Arduino Mega? 

    The address found at 0x1E is not a selectable I2C address for the TCA9548A. Is the address presented another downstream slave device present on the bus? 

    Do you have a scope capture of the I2C bus? 

    Regards,

    Tyler