FTDI Community

General Category => Discussion - Software => Topic started by: Eisenheim on November 11, 2022, 12:11:50 PM

Title: SPI read delay in FT2232H with libMPSSE
Post by: Eisenheim on November 11, 2022, 12:11:50 PM
Hi,

I have been using the ft2232H board with libmpsse module for SPI reading in windows/raspberry pi. In both cases, I read 3KB of data with 20Mhz frequency. It takes about 4ms seconds for every read. My problem is that when I read 20 minutes one or two times the read time goes above 100ms. Is it related to ftdi driver issue?

Regards,
Eisenheim
Title: Re: SPI read delay in FT2232H with libMPSSE
Post by: FTDI Community on November 14, 2022, 04:08:47 PM
Hello,

There may be a number of factors due to the nature of USB to take into consideration. If there is more USB traffic then the OS and USB have to schedule the communication with each of the USB devices.
It’s highly dependent on the OS and USB Host and is out with our control.
FTDI devices use USB Bulk transfers and those are designed to transfer large amounts of data with error-free delivery, but with no guarantee of bandwidth.
You could try disconnecting all other USB device to see if it has an effect.

You may also want to try and reduce the latency timer.
The default latency timer is 16ms when using the FTDI drivers.
The latency timer can only be set to 1ms for our USB High Speed products (like FT2232H).

You can read more about this in Data Throughput, Latency & Handshaking (https://ftdichip.com/wp-content/uploads/2020/08/AN232B-04_DataLatencyFlow.pdf).

The other option that you might want to explore is by not using LibMPSSE.
You could try using the D2xx drivers direct and implement your own SPI communication.
See AN_108 Command Processor For MPSSE and MCU Host Bus Emulation Modes (https://ftdichip.com/wp-content/uploads/2020/08/AN_108_Command_Processor_for_MPSSE_and_MCU_Host_Bus_Emulation_Modes.pdf) which should help.

Also there may be other FTDI Community users who might be able to help you further.

Best Regards,
FTDI Community
Title: Re: SPI read delay in FT2232H with libMPSSE
Post by: Mikexx on February 06, 2023, 12:30:20 PM
Hi,

I have been using the ft2232H board with libmpsse module for SPI reading in windows/raspberry pi. In both cases, I read 3KB of data with 20Mhz frequency. It takes about 4ms seconds for every read. My problem is that when I read 20 minutes one or two times the read time goes above 100ms. Is it related to ftdi driver issue?

Regards,
Eisenheim

Are you using c#? Typically the PC will hiccup through garbage collection but 100ms is a bit high.

What's the spec of your PC?

I would recommend using an application like Latencymon to check native PC latency.