|
One thing to note about the FT245R is that even though it uses 64 byte USB packets in both directions, two bytes of each IN (device to PC) packet is reserved for status information. Try writing to the FIFO in multiples of 62 instead, to avoid overruns. It may also improve bus utilization, as writing 64 bytes to the FIFO will result in two packets being generated, with 62 and 2 bytes of payload, respectively.
Edit: OTOH, the device has a 256 byte transmit buffer. If you don't write in nice powers of two, if may be impossible to determine when there is sufficient space in the FIFO or not.
Edit2: I'm starting to remember why I never implemented DMA to host transfers. The basic issue is that you have no control over when the chip sends data to the PC, so you have no actual knowledge of the state of the transmit FIFO. You can be in the middle of writing your 64-byte chunk when the host generates an IN transfer, so it's impossible to try to calculate how much space there is left.
When transferring from the host to the Saturn, you know that the device driver will send the data in as few USB packets as possible, so you know that if there's data in the receive FIFO it's either a full 64-byte package, or the final remaining bytes. You just have to make sure the command and data are sent separately.
Edit3: The FT245R does have a latency timer to make it hold off sending short packages to the host, but that still leaves the issue of the FIFO draining in 62-byte chunks. |