libftdi Archives

Subject: Re: Latency issues with ftdi_read_data() and ftdi_write_data() using libftdi-0.19

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 23 Sep 2011 10:54:27 +0200
>>>>> "KrishnaMohan" == KrishnaMohan Bandi <krishnamohan.bandi@xxxxxxxxx> 
>>>>> writes:

    KrishnaMohan> --20cf3040e9c665eee404ad850ce7 Content-Type: text/plain;
    KrishnaMohan> charset=ISO-8859-1

    KrishnaMohan> Hi all,

    KrishnaMohan>    I have a program that uses libftdi-0.19 library to read
    KrishnaMohan> and write from/to a FTDI device, which on the other end is
    KrishnaMohan> connected to an FPGA. I do not have more than 20 bytes of
    KrishnaMohan> data at any time to send/receive to/from the FTDI device,
    KrishnaMohan> however I do very frequent reads and writes (approximately
    KrishnaMohan> every 15ms) from/to the FTDI device to read the GPS clock
    KrishnaMohan> time and some other registers from the FPGA.

    KrishnaMohan> The read and write are together taking about 5-8ms and
    KrishnaMohan> sometimes it goes up to as high as 15ms. This means the
    KrishnaMohan> transfer rate is not even 9600bits/sec.  However, the baud
    KrishnaMohan> rate has been set to 921600. On the FPGA side, the time to
    KrishnaMohan> read, process, and write back the data to the FTDI does
    KrishnaMohan> not take more than 100uS. So, for the program the data is
    KrishnaMohan> available as soon as the data is written to the FTDI
    KrishnaMohan> device.

    KrishnaMohan> The strange behaviour I noticed is that when
    KrishnaMohan> ftdi_read_data() is called, it returns zero as the number
    KrishnaMohan> of bytes read. 

Are you sure the data has already been delivered to the FTDI chip? Have a
deep look at 
http://www.ftdichip.com/Support/Documents/AppNotes/AN232B-04_DataLatencyFlow.pdf
to understand the issues involved.

Chapter 3.1, point 2 might help: Toggle some status line when the device has
send the data to the FTDI chip.

    KrishnaMohan> Only, the third (always) time the
    KrishnaMohan> ftdi_read_data() actually reads the data and about 3ms is
    KrishnaMohan> elapsed between the time the data is available and the
    KrishnaMohan> ftdi_read_data() is actually able to read the data from
    KrishnaMohan> the FIFO.


    KrishnaMohan> What I want to know from you guys is why is
    KrishnaMohan> ftdi_read_data() takes so much time to read small amount
    KrishnaMohan> of data? What should be done to reduce the read/write time
    KrishnaMohan> to the FTDI?

Is this with a x232H chip or an old type USB full speed chip. In the
latter case, add a USB2.0 High-Speed Hub in between. 

...

    KrishnaMohan> Hi all,<br><br>=A0=A0 I have a program that uses

Please, no HTML in Mail.
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread