Hello. I am trying to setup a data transfer for my device over USB. I have this functional, and transmitting to a Labwindow CVI GUI.
It is timer based, and set to 600 Hz. Before each call to USBBufferWrite I set a flag to block any other transmits from the timer. Then upon USB_EVENT_TX_COMPLETE event in my tx handler, I clear the flag. In this way I have setup a blocking transmit (though blocking may not be the right word, it will not allow multiple transmits at the same time in the buffer). I am sending a struct of my data and so I know the exact size of it (310 Bytes).
Setting my tx buffer size to the exact size of the struct was not enough, however, as the last few bytes were not making it to the USB host (the computer/GUI in this case) (only 309 bytes seen). This was fine with me, as I simply increased the buffer size to the next power of two (512) and transmitting data worked (at least singluarly, not 600Hz yet). Though, if anyone has a answer to why this didn't work, I would love to hear it.
I then experimented with increasing the speed to 600 Hz, and occasionally it became out of sync and not sending the full number of bytes from USBBufferWrite. This does not make sense to me as it should be blocking, and the tx buffer should therefore be enough to fit 310 bytes each time right?
Note, the only place the flag is cleared is in USB_EVENT_TX_COMPLETE, and the only place that USBBufferWrite is called is from that timer.