General Category > Discussion - Software

What error is returned if an I2C Write/Read times out?


It is my understanding that FT_SetTimeouts() will cause a Read/Write to timeout. How can you tell if this happened? I did not see an obvious return code.

--- Code: ---ftStatus = FT_SetTimeouts (ftHandle, 5000, 5000);


ft4222Status = FT4222_I2CMaster_Read (ftHandle, address, buffer, bufferSize, &sizeTransferred);

--- End code ---

In this I2C example, suppose the slave device invoked clock stretching and held it longer than 5000ms. I would expect the Read call to return due to the SetTimeouts.

We sometimes see unexpected FT4222_FAILED_TO_READ_DEVICE errors, so I added code to print any time "bufferSize" and "sizeTransferred" do not match (and did the same in the Master_Write. I am not seeing those print, but I do see the program hang for 5 seconds from time to time, which makes me think it's being stuck in I/O then timing out.

Thanks, much. I am working on a project that uses FTDI I2C to communicate between a host PC and almost 30 boards using a write/read protocol. While it's been proven very solid (I've personally tested it with over 41 million messages with 0 errors), if/when a line glitch does happen, I want to make the master code robust.

FTDI Community:

When FT_SetTimeouts() is not used, standard d2xx read and write API's would not return as they are blocking calls.

When FT_SetTimeouts() is set to say 5 seconds, that would give plenty time for Read and Write API calls and it would return if there were any issues with the Read or Write.

Best Regards,
FTDI Community


[0] Message Index

Go to full version