FTDI Community

General Category => Discussion - Drivers => Topic started by: allenhuffman on August 26, 2019, 10:56:01 PM

Title: [Confirmed Bug] FT4222_I2CMaster_Write sizeTransferred returning 4 extra bytes.
Post by: allenhuffman on August 26, 2019, 10:56:01 PM
Somewhere I read that FTDI added some header bytes that needed to be accounted for. I cannot find where I saw this, but maybe this is what I am seeing.

Per the App Note 329, I am using FT4222_I2CMaster_Write() and passing in a value of 8 for "bytesToWrite", and a zeroed out sizeTransferred before passing it in. "sizeTransferred" returns as 12 rather than the 8 I expected. (Verifying with a line analyzer shows the 8 bytes we went without extras.)

What are the extra 4 bytes?
Title: Re: FT4222_I2CMaster_Write sizeTransferred returning 4 extra bytes.
Post by: FTDI Community on August 29, 2019, 09:14:43 AM
Hello,

In general with USB full speed 64 bytes transfer package is made up of 2 status bytes and 62 user bytes.
Note this is 512 maximum transfer package size for USB high speed like the FT4222H.
The two bytes 02 60 are the status bytes required by the D2XX driver.
The status bytes are for the driver and should be invisible to the user application and is handled by the driver.

Which version of LibFT4222 are you using? Which version of the D2XX driver are you using?
The latest are v1.4.2 and 2.12.28 respectively (for Windows).

Which FT4222H IC revision are you using?

Have you tested out the I2C examples provided with LibFT4222?

Best Regards,
FTDI Community
Title: Re: FT4222_I2CMaster_Write sizeTransferred returning 4 extra bytes.
Post by: allenhuffman on August 29, 2019, 02:39:21 PM
Which version of LibFT4222 are you using? Which version of the D2XX driver are you using?
The latest are v1.4.2 and 2.12.28 respectively (for Windows).

I am using the latest ZIP, downloaded recently:

LibFT4222-v1.4.2.zip

Quote
Which FT4222H IC revision are you using?

D

Quote
Have you tested out the I2C examples provided with LibFT4222?

I am currently using a modified example, yes.

When I use FT4222_I2CMaster_Write() and tell it to write 7 bytes, the value returns with 11. I've tested it with other numbers, and see it returns 4 higher than what I passed in. Here's a slightly edited snippet:

Code: [Select]
sizeTransferred = 0;
ft42Status = FT4222_I2CMaster_Write(FTDIHandle, slaveAddress, writeBuf, (ushort)sizeToWrite, &sizeTransferred);

Writing 7 bytes...
11 SENT: aa 00 06 00 02 4e ff


As you see, I clear sizeTransferred before I pass it in.
Title: Re: FT4222_I2CMaster_Write sizeTransferred returning 4 extra bytes.
Post by: FTDI Community on August 30, 2019, 04:39:21 PM
Hello,

This is confirmed as a bug in FT4222_I2CMaster_Write().
It will be fixed with the next LibFT422 patch.
However the actual transaction is OK and the extra count of 4 can be discarded as a workaround.

Best Regards,
FTDI Community
Title: Re: FT4222_I2CMaster_Write sizeTransferred returning 4 extra bytes.
Post by: allenhuffman on August 30, 2019, 07:00:57 PM
Awesome! Thanks for the confirmation.
Title: Re: [Confirmed Bug] FT4222_I2CMaster_Write sizeTransferred returning 4 extra bytes.
Post by: allenhuffman on April 23, 2020, 05:50:18 PM
Looks like this is fixed in 1.4.3 (but we haven't tried it yet):

Release version
1.4.3 (Mar 19, 2020)
Maintenance release.

Release Fixes

•   Support Chip version “A”, “B”, “C” and “D”.
o   Fix issue. FT4222_I2CMaster_WriteEx does not return correct sizeTransferred.
Title: Re: [Confirmed Bug] FT4222_I2CMaster_Write sizeTransferred returning 4 extra bytes.
Post by: allenhuffman on December 04, 2020, 08:12:00 PM
I do not think it was actually resolved in 1.4.3, but it definitely works in 1.4.4.