libftdi Archives

Subject: Re: Problems with FT232R in bitbang mode

From: Helge Lenz <h.lenz@xxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 18 May 2010 19:03:47 +0200
Thomas Jarosch schrieb:

On Friday, 14. May 2010 22:48:07 Helge Lenz wrote:
So is there any way to make it work with this type of chip or should I
stop trying and use something else? The one thing that I have not tried
so far is to put the signal to one of the CBUS lines and use the CBUS
bitbang mode. So could this be an option to make it work? Or should I
use the D2XX library for linux instead of libftdi?

I would really appreciate some hints.

The USB bus doesn't give you a guarantee about the timing, so it might
be too slow to properly modulate a clean carrier signal. There is the
isochronous USB mode which sounds suitable for this kind of application,
though it doesn't handle USB packet loss at all.

Maybe add a small microcontroller to act as a receive buffer and to modulate a clean carrier signal? Then you are in control what is happening
with the signal...


libftdi - see for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
Ok, taking a microcontroller would of course work but would be more complicated...

But how does sending bytes in bitbang mode really works? I thought I send a number of bytes in one operation to a buffer in the chip and the logic reads the buffer at BAUDRATE speed and sets the corresponding I/O lines to high or low according to the value. Why should the speed of the USB have any impact on the timing between single bytes if they are sent in one operation?

Lets take a very simple example:
#include <stdio.h>
#include <ftdi.h>
#include <sys/time.h>

int main(void)
 struct ftdi_context ftdic;
 unsigned char testbuf[3];

 ftdi_usb_open_desc(&ftdic, 0x0403, 0x6001, NULL, NULL);
 while (!0)

 return 0;
Is there something wrong with this example (except from checking return values etc...)? What am I going to measure with my scope? I would say I should measure a peak of 6.51 µs according to FTDI specs (baudrate * 16) or 13.02 µs according to other specs (baudrate * 8). What I really measure is most of the time 3.24 µs (baudrate * 32?????) and sometimes 14.7 µs and seldom 17.7 µs. Any explanation? I then extended the testbuf to 7 bytes (0101010) and now I NEVER see three equal pulses and space between them on my scope. Why do I have bitbang mode if it is like this??? Ok, I increased the baudrate to 65536 (as suggested by Albert Huitsing) and now I see three equal spaced peaks and spaces very stable. If I increase the buffer to 9 bytes (011100010) I see most of the time a stable peak and space followed by a single peak but sometimes only a single peak. How can this all fit together?

Sorry, I am a little bit lost here. Either I have totally misunderstood the whole thing or the FT232RL is just not made for this mode.


libftdi - see for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
Current Thread