FTDI USB devices and BitBang

USB made simple

RS232 and Parallel Ports are fast becoming obsolete and several developers are looking to easy USB solutions,  e.g on our AT89LP evaluation boards we are using a RS232 - SPI converter logic and we use an additional USB - RS232 converter with hardware handshaking. This is working, but slow (in this case 2k Flash Programming will take some minutes)
The reason: The Data transfer is limited by USB frames (~one Byte per frame when using byteread/bytewrite with RS232 Port Dll's and VCP drivers).

One possible Solution:

A special 'Bit Bang' Mode of some FTDI devices (232BM / 245BM / 232R / 2232 see: www.ftdichip.com ) replaces the normal mode and the device control lines can be used as an 8bit bi-directional bus. (for the 232BM: TxD ist Databit0, RxD is Databit1...RI is Databit 7)

[FTDI]: Any data written to the device in the normal manner will be self clocked onto the data pins (for the pins that have been programmed as outputs). Each pin can be set as an input or an output independant of the other pins. The rate of clocking out the data is controlled by the baud rate generator. If you do not write any new data to the device then the pins will hold the last value written.

FTDI also supplies a set of drivers that will allow you direct access to the control lines. These drivers (D2XXX driver) are provided as separate DLL files that present a relatively simple interface to VB, VC++, C+ Builder, Delphi etc. If you want to test this and you are using the FTDI Virtual COM Port (VCP) drivers, then you might have to remove the VCP drivers before you install the direct D2XX drivers.
You can use the USBVIEW utility to check your driver installtion.

The D2XXX commands of interest are :

1) FT_SetBaudRate(ftHandle : Dword ; BaudRate : Dword) 
This controls the rate of transferring bytes that have been written to the device onto the pins. It also sets the sampling of the pins and transferring the result back to the Read path of the chip.
2) FT_SetBitMode (ftHandle : Dword ; ucMask , ucEnable : Byte)
sets up which bits are input and which are output. The ucMask byte sets the direction. A ‘1’ means the corresponding bit is to be an output. A ‘0’ means the corresponding bit is to be an input. When read data is passed back to the PC, the current pin state for both inputs and outputs will used.
3) FT_GetBitMode ( ftHandle : Dword ; pucData : pointer )
This function does an immediate read of the 8 pins and passes back the value. This is useful to see what the pins are doing now.
4) FT_Write
Data can be written to the device in Asynchronous and Synchronous Bit Bang mode using the FT_Write command. If multiple bytes are written to the device the values on the pins will change at the rate set by FT_SetBaudRate. 
5) FT_Read
FT_Read will return a buffer of values which have been sampled from the pins at the rate set by FT_SetBaudRate. If the read buffers have filled, data willl be lost. Each byte returned contains the values of the pins, both those which are inputs and those which are outputs.

These commands will allow you to tranfer a couple of hundred Bytes in one USB frame. Just fill the write buffer with the bytes, set the appropriate baudrate and bit mode and perform the FT_Write command. Don't forget to reset the bit Bang Mode.

At least you also should have a look to the CBUS Bit Bang mode and to the Synchronous Bit Bang Mode of the 232R and 2232C devices. The Synchronous Bit Bang mode will read the data bus pins first, before it sends out the byte. For the 2232C device you also can get an USB SPI or I2C Converter. In case of interest you will find some 'MPSSE Example Projects' on FTDI's hompage.

Our new USB LP Programming adapter will support these functions ... and some additional features....


Any input is welcome: Mail
j.hulzebosch@gms2000.de