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.

Using TCA6416 IO expander chip to enable IO ports and access LEDs

Other Parts Discussed in Thread: TCA6416

Hi experts,

We are trying to access 4 LEDs connected on P0-7 and P1-0 to P1-3, without affecting the other pins since those port pins are connected to the reset / enable pin of particular modules.

Since LED access is like GPIO access over I2C bus, we tried the following using I2C bus read / write transactions,

1. Read the configuration register for Port 0 and Port 1, mask accordingly to set the direction of pins connected to LED as output. Then write to the configuration register with the corresponding values

2. Read input port register for Port 0 and Port 1, mask accordingly to set the output for LEDs, and write to the output port register with the corresponding value.

But on access using the above steps, it affects the other pins which is not expected, even though we access each 8 bit register independently, and write to the particular IO pins without affecting other pin direction / value.

Searching on net, we found the following algorithm for setting the IO expander,

1. Read Output register

2. Mask accordingly

3. Write value to Output register

4. Read Direction register (Note 0 == output, 1 == input)  a. if input, Write Direction register

5. Read Input register for returning

This algorithm confuses us , since after setting the o/p port register , the direction is set, which is a reverse approach of traditional GPIO access.

We don't find any reference on the TCA6416 datasheet to know the sequence to set the output port register.

Please guide us on how we could access TCA6416 to set the output port registers and glow the LEDs.

Also consider we don't have provision for sysfs GPIO access, and only through I2C transactions

Thanks in advance,

Dhiv