FTDI Community

General Category => Discussion - Hardware => Topic started by: Cactus on February 20, 2018, 09:46:09 AM

Title: FT4222H Slave Losing bytes
Post by: Cactus on February 20, 2018, 09:46:09 AM
Hi I was wondering if anyone would be able to provide me with a reason the FT4222h is losing bytes.
I am currently using the FT4222h in slave mode, with a microprocessor as master.
The microprocessor sends parcels 6630 bytes every 4ms. Using a Labview program, I poll the "SPI Slave Get Rx Status" and read when there are incoming bytes.
Occasionally the FT4222h has missed bytes and the next parcel has "merged" with the previous parcel.
E.g if i am sending a parcel of 0-6629, one parcel may come up 0,1,2,...4560,4561,90,130,1,25,230,0,1,2,3,...
where 90,130,1,25,230, is the protocol for the packet.
This occurs very infrequently, however I am requiring a high fidelity system, so losing bytes is not ideal.
I have set the latency as 4ms and the Transfer size for USB IN request to 6656 bytes. Slave is set as SPI_SLAVE_WITH_PROTOCOL.
Title: Re: FT4222H Slave Losing bytes
Post by: FTDI Community on February 21, 2018, 10:52:16 AM
Hello,

We recommend that you place a known starting byte at the beginning of each data packet.
There is no guarantee that your data packets will align correctly with USB packets, as the USB host is responsible for scheduling transfers. The best approach would be to try to achieve the greatest throughput possible and sort out the data once in Labview.

Best Regards,

FTDI Community
Title: Re: FT4222H Slave Losing bytes
Post by: Cactus on February 22, 2018, 07:40:56 AM
Thanks for the advice, I'll give it a shot.
I've had a read through "AN232B-03 Optimizing D2XX Data Throughput"  and there are a few things which I am still unsure about. Perhaps would you know?
Title: Re: FT4222H Slave Losing bytes
Post by: FTDI Community on February 22, 2018, 02:34:16 PM
Hello,

Maintaining the data in packets as close to multiples of 62 may be beneficial, however the number of packets required to send 6630 bytes of data and 6634 bytes of data is the same at 107.

The FT4222_GetMaxTRansferSize function returns the maximum packet size in a transaction. Thus keeping your data packets within the value returned would ensure only one USB transaction is required to transfer the whole packet.

It may be worth experimenting with the your data packet size to establish what returns the best result.

Best Regards,

FTDI Community