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.

TCA9539: I2C Port 0 and Port1 detection issue

Part Number: TCA9539

Dear Team,

We've successfully scanned the TCA9539 device but are facing challenges configuring the I/O pins as outputs. Following the datasheet instructions, we attempted to configure P00 to P07 as outputs by writing 0x02 (output port 0) to 0x06 (configuration Port 0):

i2cset -f -y 2 0x74 0x02 0x06

However, despite this, the state of the respective GPIOs did not change when checked under /sys/class/gpio and checked with multimeter.

Could you please provide guidance on how to correctly configure these pins as outputs of Port 0 pin 2 ?

Waiting for your response.

Thanks & Regards,

Vishal Mistry

  • You have to set the desired pin values in register 2, and you have to configure their directions in register 6:

    i2cset -y 2 0x74 0x02 0x...
    i2cset -y 2 0x74 0x06 0x00

  • Hi Vishal,

    Clemens is correct here. You must set both bits in the output port and configuration registers for the outputs on P0x pins to work properly. This would require two i2cset commands. 

    For port 0 pin 2 as output

    i2cset -y 2 0x74 0x02 0x...
    i2cset -y 2 0x74 0x06 0x00

    Regards,

    Tyler

  • Dear Sir,

    Thank you for your guidance. Now we are able to access port.

    We managed to configure pins p0 to p17, except for p12 and p13. Unlike other pins, these GPIOs have a default high state. I've grasped that writing values to the output port register determines the change in GPIO values, along with writing 0 to the configuration port register.
    Could you explain what determines the values written to the output register?

    For pins p0 to p7, the values written to the outport 0 register are 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, and 0x80 respectively. The default GPIO state of these pins was 0, but it changes to 1 after writting these values. Similarly, for pins p10 to p17, the same pattern follows except for p12 and p13, and their default state(value 1) does not change.

    Kindly share your inputs 

    Thanks & Regards,

    Vishal Mistry

  • Hi Vishal,

    Was port 1 configured as output? 

    The configuration register is divided across two ports. 

    To configure both ports to be output, you need to write to both configuration port registers. 

    This would include...

    i2cset -y 2 0x74 0x06 0x00

    i2cset -y 2 0x74 0x07 0x00

    The first i2cset command will set Port 0 to all outputs (P00 - P07)

    The second i2cset command will set Port 1 to all outputs (P10 - P17)

    Regards,

    Tyler