Hi,
I was using TCA9535(I/O Expander) interface with LPC55S16 microcontroller. We use the I2C communication to communicate with I/O Expander. Set the I2C with given device address,register address and 16 bit data passes through TCA9535.But the I/O Expander can't response with given configuration.
Use a logic analyzer or scope, and check if the slave responds with an ACK to the address.
Hi,
I have searched on Google, the TCA9535 is TI product, this is the website of TCA9535:
The I2C of LPC55S16 is the master, the I2C of the TCA9535 is slave.
The 7 bits I2C slave address is dependent on the A0/A1/A2 pins connection, if the A0/A1/A2 pin are all connected to GND, the I2C address will be 0x20.
If you want to set/clear the Port logic of TCA9535, you have to set the corresponding bit as 0 in configuration register, then write the port logic.
This is the sequence of writing configuration reg:
I2C slave address + configuration register address + configuration register data
In SDK example, there is I2C example.
#define #I2C_MASTER_SLAVE_ADDR_7BI 0x20
#define #I2C_DATA_LENGT 1
deviceAddress=0x06; //configuration reg
g_master_txBuff[0]=0;
/* subAddress = 0x01, data = g_master_txBuff - write to slave.
start + slaveaddress(w) + subAddress + length of data buffer + data buffer + stop*/
uint8_t deviceAddress = 0x01U;
masterXfer.slaveAddress = I2C_MASTER_SLAVE_ADDR_7BIT;
masterXfer.direction = kI2C_Write;
masterXfer.subaddress = (uint32_t)deviceAddress;
masterXfer.subaddressSize = 1;
masterXfer.data = g_master_txBuff;
masterXfer.dataSize = I2C_DATA_LENGTH;
masterXfer.flags = kI2C_TransferDefaultFlag;
Hope it can help you
BR
XiangJun Rong
Thank you for the Code flow Mr.@xiangjun_rong
Hi @xiangjun_rong ,
What if we try in the I2C polling method?.Because I was actually try in the I2C polling method.Where I was got only slave address but not got a register address and the data.
Hi,
If you use the polling mode, you have to write register and develop the code yourself.
BR
XiangJun Rong