· | Pins start at 0xFF
|
· | Send 0x55, 0xAA
|
· | Pins go to 0x55 and then to 0xAA
|
· | Data read = 0xFF, 0x55
|
· | Pins start at 0xFF
|
· | Send 0x55, 0xAA, 0xAA (repeat the last byte sent)
|
· | Pins go to 0x55 and then to 0xAA
|
· | Data read = 0xFF, 0x55, 0xAA
|
The timing for Synchronous Bit bang is described in this diagram and the table below:
Time
|
Description
|
t1
|
Current pin state is read
|
t2
|
RD# is set inactive
|
t3
|
RD# is set active again, and any pins that are output will change to the new data.
|
t4
|
Clock state for data setup
|
t5
|
WR# goes active
|
t6
|
WR# goes inactive
|
For the data to change there has to be new data written and the Baud rate clock has to tick. If no new data is written to the device, the pins will hold the last value written.
When Synchronous Bit Bang mode is enabled the IO signal lines are configured as follows:
FT232RL/ FT245RL Pin Number
|
FT232RQ/ FT245RQ Pin Number
|
Signal |
Type |
Description |
1
|
30
|
D0
|
Input/Output
|
Bit Bang Data Bus Bit 0
|
5
|
2
|
D1
|
Input/Output
|
Bit Bang Data Bus Bit 1
|
3
|
32
|
D2
|
Input/Output
|
Bit Bang Data Bus Bit 2
|
11
|
8
|
D3
|
Input/Output
|
Bit Bang Data Bus Bit 3
|
2
|
31
|
D4
|
Input/Output
|
Bit Bang Data Bus Bit 4
|
9
|
6
|
D5
|
Input/Output
|
Bit Bang Data Bus Bit 5
|
10
|
7
|
D6
|
Input/Output
|
Bit Bang Data Bus Bit 6
|
6
|
3
|
D7
|
Input/Output
|
Bit Bang Data Bus Bit 7
|
In the case of the FT232R, CBUS0/CBUS1/CBUS2/CBUS3 can be configured to bring out the internal RD# strobe and CBUS0/CBUS1 can be configured to bring out the internal WR# strobe when the device is in Synchronous Bit Bang mode. Alternatively, the CBUS pins can be used to provide clock signals by setting the appropriate values in the EEPROM. The CBUS must be configured in the FT232R EEPROM. This option is not available for the FT245R.
FT232RL Pin Number
|
FT232RQ Pin Number
|
Signal |
Type |
Description |
23
|
22
|
C0
|
Input/Output
|
Configurable function
|
22
|
21
|
C1
|
Input/Output
|
Configurable function
|
13
|
10
|
C2
|
Input/Output
|
Configurable function
|
14
|
11
|
C3
|
Input/Output
|
Configurable function
|
A number of D2XX driver commands are needed to use Synchronous Bit Bang mode. The commands of interest are listed below:
D2XX Function
|
Description
|
FT_SetBitMode
|
Synchronous Bit Bang mode is enabled using the FT_SetBitMode command. A value of 0x04 will enable it and a value of 0x00 will reset the device mode.
|
FT_SetBaudRate
|
The rate of data transfer can be controlled by using the FT_SetBaudRate command. The maximum Baud rate is 3MBaud, but to allow time for the data to be setup and held around the WR# strobe the Baud rate should be less than 1MBaud.
The clock for the Synchronous Bit Bang mode is actually 16 times the Baud rate. A value of 9600 Baud would transfer the data at (9600x16) = 153600 bytes per second, or 1 every 6.5 mS. |
FT_Write
|
Data can be written to the device in 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.
|
FT_GetBitMode
|
FT_GetBitMode returns the instantaneous value of the pins. A single byte will be returned containing the current values of the pins, both those which are inputs and those which are outputs.
|
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.
|
Full descriptions of these functions are available in the D2XX Programmer's Guide.
Code examples can be downloaded from http://www.ftdichip.com/Projects/CodeExamples.htm.