Skip to main content
RCooke88
Associate III
January 29, 2023
Solved

I'm trying to use the I2C multiplexer TCA9548A and I can't seem to get any output from the output ports.

  • January 29, 2023
  • 3 replies
  • 5957 views

I'm using the Nucleo32L031 board connected to a Adafruit TCA9548A 1:8 multiplexer board. I have the board setup properly, Vcc = 3.3, GND, SCA and SCL pins double checked. I have a Sparkfun TMP102 temp sensor board connected to the TCA9548A's port0.

I set the mux channel with:

HAL_StatusTypeDef ret;

uint16_t TCA9548A_ADDR = (0x70 << 1); //default address is 0x70

uint8_t current_buf[3];

channel_buf[0] = 0;

ret = HAL_I2C_Master_Transmit(&hi2c1, TCA9548A_ADDR, channel_buf, 1, 15000); // sets TCA9548A output channel to port 0

ret = OK here

Then I try to communicate with the temp sensor TMP102:

uint16_t SEN_13314_ADDR = (0x48 << 1); // default address is 0x48

uint8_t temp_buf[3];

ret = HAL_I2C_Master_Receive(&hi2c1, SEN_13314_ADDR, temp_buf, 2, 5000);

ret != OK here

I've checked all of the pull-ups are correct. If I connect the TMP102 I2C lines directly to the Nucleo's I2C lines I can read the temperature. I just can't using the mux.

Has anybody successfully used the TCA9548A chip? Any ideas?

Thanks,

Richard

This topic has been closed for replies.
Best answer by MM..1

read datasheet better, 0 = all chan disabled

use 1 2 4 8 ... and all 8 bus require own pullups

3 replies

S.Ma
Principal
January 29, 2023

Would a bigger package STM32 and SW bit-bang IO (2x8 pins) do the job or voltage translation is the most important need here?

When switching channels, I guess you'll need pull ups on each I2C branch to avoid glitches during mux change. you should change channel only when all SDA and SCL are high, and your mux chip slave address must be different than the temp sensor.

RCooke88
RCooke88Author
Associate III
January 29, 2023

I'm going to need to control 5 I2C devices so bit banging is the best option. I have pull-ups on all of the outputs. According to my logic analyzer there is no output from the TCA9548A ports at all. Which leads me to believe that I'm not setting that chip up properly but I can't figure out what I'm doing wrong.

MM..1
Chief III
January 29, 2023

Your chip sint gpio ... Features 1• 1-to-8 Bidirectional translating switches

Read datasheet TCA need settup once config pin register where is set in out mode.

Plus why 15000 timeout ???

RCooke88
RCooke88Author
Associate III
January 29, 2023

I picked 15000 timeout just because it's shorter than HAL_MAX_DELAY. What is the "normal" value for the timeout?

I've read the TCA9548A datasheet and it looks like all I need to do is write the output port number to turn that one on. I'm sending a '0' to the chip by:

HAL_I2C_Master_Transmit(&hi2c1, TCA9548A_ADDR, channel_buf, 1, 15000); // channel_buf[0] = 0. The output from port 0 stays high (due to the pull-ups) and never changes according to my logic analyzer.

MM..1
MM..1Best answer
Chief III
January 29, 2023

read datasheet better, 0 = all chan disabled

use 1 2 4 8 ... and all 8 bus require own pullups

S.Ma
Principal
January 29, 2023

Obviously here the I2C Mux means it's time multiplexed and 100 kbps is easily doable by bit bang.

Note that you could generate 5 I2C buses with 10 IOs without the need of an external mux.

Here you can find I2C Master bitbang implemneted for STM32C0, easy to adapt to any STM32.]

Besides improving the SW Delay, the rest should work fine and be I2C Error proof.