Hi,
I am using TIVA4c123 to communicate through USB with an application in my laptop (that uses libusb).
The laptop is the HOST.
I have defined a number of transfers so the HOST asks/sends data to my device.
I am using TIVAware libraries and the USB communication is bulk.
Everything works really fine, I have all the check for errors and I never have errors in both sides(HOST/DEVICE).
There are 2 main transfers:
1) the HOST continuously request a specific data to the device (18bytes)
2) the HOST send asynchronously a command to the device to activate some functions
My problem is that sometimes when I send the transfer 2) I receive the COMPLETION of the transfer 1) with the data buffer of the transfer 2 + I receive the COMPLETION of the transfer 2 but with wrong date in the buffer. It does not happen always but let me say....every 5-10 times I send the transfer 2). This happens without any errors.
I spent a lot of time on the SW (laptop side) to make sure the transfer 1 and 2 can't be requested at the same time....so transfer1 can be done only if tranfer2 is completed and vice versa.
Looking at the local buffer used on TIVA side, the data are always sent correctly...so..something happens a lower level in the Tiva USB driver...somehow the 2 transfers are mixed. I use USBBufferFlush for the TX buffer before to use it and for the RX buffer after buffer has been read. I use USBBufferRead/USBBufferWrite to read/write the buffers...
If somebody has experienced a similar issue or has suggestions...I am running out of ideas...
These are the libraries I am using:
#include "driverlib/usb.h"
#include "usblib/usblib.h"
#include "usblib/usb-ids.h"
#include "usblib/device/usbdevice.h"
#include "usblib/device/usbdbulk.h"
#include "usb_bulk_structs.h"
here below and ide of what happens HD (host->device) DH (devce->host). This is while I ma monitoring transfer #2.
HD-----> "1" "0" "1" "1" "0" "40" "39" "4" "5" "0" "4" "0" "0" "0" "0" "0" "0" "0" "0"
DH<----- "1" "0" "1" "1" "0" "40" "39" "4" "5" "0" "4" "0" "0" "0" "0" "0" "0" "0" "0"
HD-----> "1" "0" "0" "1" "0" "40" "39" "4" "5" "0" "4" "0" "0" "0" "0" "0" "0" "0" "0"
DH<----- "1" "0" "0" "1" "0" "40" "39" "4" "5" "0" "4" "0" "0" "0" "0" "0" "0" "0" "0"
HD-----> "1" "0" "1" "1" "0" "40" "39" "4" "5" "0" "4" "0" "0" "0" "0" "0" "0" "0" "0"
DH<----- "1" "0" "1" "1" "0" "40" "39" "4" "5" "0" "4" "0" "0" "0" "0" "0" "0" "0" "0"
HD-----> "2" "0" "1" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0"
DH<----- "2" "0" "1" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0"
HD-----> "2" "0" "0" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0"
DH<----- "2" "0" "0" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0"
HD-----> "2" "0" "1" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0"
DH<----> "2" "0" "1" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" <------- this is tranfer #1 length and tranfer #2 data
DH<----- "0" "0" "0" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0" <------- this is tranfer #2 with wrong data (it should match the HD).
HD-----> "2" "0" "0" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0"
DH<----- "2" "0" "0" "1" "3" "40" "11" "12" "5" "0" "8" "0" "0" "0" "0" "0" "0" "0" "0"