Increasing your FTDI Chip’s Efficiency
When you are using a USB serial port based on the popular 232BM FTDI chip set, there are some things you can do to make your transfer of data faster and prevent the loss of transferred data. Since the serial device uses USB bus bulk transfers, the time that data goes back and forth can vary if there is other traffic from other devices on the bus competing with it like video or audio isochronous transfers. This might not be quite a problem because the data has to sent and received at a slower baud rate at the RS232 port end. If you think about it, the FTDI virtual com port driver or their more direct D2XX driver have the ability to transfer up to 300 kbs and 1 Mbs respectively, this top speed is faster (like 1000 baud) than most of your typical RS232 serial ports.
There is an interesting setting for minimizing latency in the driver. If you only need to transfer 62 bytes or less, the D2XX driver has a setting that can change its latency timeout from its standard value of 16 milliseconds to a range of 1 to 255 milliseconds. At the shortest setting, the FTDI driver will send status bytes with included data at a periodic 1-millisecond rate depending on bulk IN packets (to the PC host) being acknowledged with a USB ACK packet.
Another nice latency controlling feature is that you can define an event character with the D2XX driver that will enable the host to request a device to transfer its data immediately. When this event character is received, the FTDI controller sends status messages with up to 62 data bytes in the packet. This special character is part of your data that you send and the hardware controller takes it out automatically. There are also external lines that you can cause a transfer to occur. Filling up the transmit buffer to 62 bytes will also cause an immediate transfer.
If you aren’t using handshake lines of your serial port, you probably want to know that the 232BM has a 384 byte buffer for data going into the PC host and a 128 byte buffer going out. This is because of the bulk transfer nature of the USB serial port class (or CDC more exactly). There is no guarantee that the PC host will request the data and the USB bus could also be busy even when a request is make. This is one of the main timing differences to keep in mind while using these types of serial ports as compared to the traditional serial ports on a PC. The similarly functioning 245BM USB parallel port interface chip set that FDTI also makes has the same buffer sizes for its inputs and outputs.
Related posts:
Hi,
Fantastic post.
I really admire this kind of information.
Thanks for tips and advice.
As i often need to write with my online site a little something the same as yours somehow you’ve made a number of nicely things here. I probably did searches on to the main subject and also discovered most visitors definitely will agree for your current blog.Great post!