AnsweredAssumed Answered

I2C Slave driver failing every other transfer

Question asked by Craig Corbin on Mar 20, 2019
Latest reply on Mar 25, 2019 by Daniel Chen

I am trying to use the I2C interrupt driver on MQX 4_1_1. I am running it as a slave and I am having an issue where I am losing every other read transfer. Basically this is what is happening.

 

1 -I write my data with fwrite

2 -Wait to be addressed

3 -Master reads the data

 

The next time the master addresses the slave the Slave does not respond. I see the address on the bus but the slave does not respond with an ACK

 

After this failed attempt if the master addresses the master again the transfer works as expected. Below is the code that I am using 

 

ioctl(mComPort, IO_IOCTL_I2C_SET_STATION_ADDRESS, &param);     
fwrite((uint8_t *)(buff_ptr), 1, 1, mComPort);       
while (numBytesToWrite > 0)   
{     
   bytesWritten = fwrite((uint8_t*)(buff_ptr + numBytesWritten), 1, 1, mComPort);      
   numBytesWritten += bytesWritten;      
   numBytesToWrite -= bytesWritten;   
}    

ioctl(mComPort, IO_IOCTL_FLUSH_OUTPUT, &param);      
ioctl (mComPort, IO_IOCTL_I2C_STOP, NULL);

 

I have tried various iterations of using IO_IOCTL_I2C_SET_RX_REQUEST but I have no idea why I the slave is not responding to a second read request after the first transfer finishes. 

Outcomes