Part Number: TMS320F28075
Other Parts Discussed in Thread: TCA9539, CONTROLSUITE
I am currently using an I2C interface to communicate with the TCA9539 GPIO expander. I have gotten read operations to the chip to work, which require a repeated start condition as listed below. I've noticed, though, that the while loop that waits for ARDY to clear takes a substantial amount of time to complete. Is there a way to setup the I2C registers to autonomously perform the repeated start condition (as I demonstrated) without having to wait for ARDY to set (or using interrupts)?
A follow-up question to the first is that using the code below, I can see on my oscilloscope that repeated start is initiated and two bytes are transmitted back. However, no bytes are read from the RX FIFO when accessing I2CDRR. If I change the code below and set RM for repeat mode, I can see the data received by accessing I2CDRR (but only one byte is received because the number of transmissions is no longer dependent on I2CCNT, as expected).
if(i2c_regs->I2CMDR.bit.STP || i2c_regs->I2CSTR.bit.BB) {
return;
}
// set the I2C address
i2c_regs->I2CSAR.bit.SAR = 0x77;
i2c_regs->I2CCNT = 1;
// PORT0 inputs are at address 0
i2c_regs->I2CDXR.bit.DATA = 0;
i2c_regs->I2CMDR.bit.IRS = 1;
i2c_regs->I2CMDR.bit.MST = 1;
i2c_regs->I2CMDR.bit.TRX = 1;
i2c_regs->I2CMDR.bit.STP = 0;
i2c_regs->I2CMDR.bit.STT = 1;
// wait for I2C register settings to be used
while(i2c_regs->I2CSTR.bit.ARDY == 0);
// set number of bytes to expect
i2c_regs->I2CCNT = 1;
// send start as master transmitter
i2c_regs->I2CMDR.bit.IRS = 1;
i2c_regs->I2CMDR.bit.MST = 1;
i2c_regs->I2CMDR.bit.TRX = 0;
i2c_regs->I2CMDR.bit.STP = 1;
i2c_regs->I2CMDR.bit.STT = 1;