About the usb port in my PIC

Thread Starter

ahgan84

Joined Dec 19, 2011
55
Currently using the PIC18F25k50 and I want to send data through it's usb port. I'm using the below coding to do usb transmitting:

Rich (BB code):
 if(!HIDTxHandleBusy(USBInHandle))    
 {    
       USBInHandle = HIDTxPacket(HID_EP,(BYTE*)&ToSendDataBuffer[0],64);    
 }
Is it that my data will straightaway transmit out after it reach the 'HIDTxPacket' function? Or it waits awhile and only send out in the background? How do we know that our protocol got successfully sent out?

I'm sending four protocols out at one time. Protocol A (11 bytes data + 53 bytes 0x00), Protocol B (15 bytes data + 49 bytes 0x00), Protocol C (30 bytes data + 34 bytes 0x00) and Protocol D (11 bytes data + 53 bytes 0x00).

I'm asking this because sometimes my receiver device miss out some data that I transmit out and usually it misses out protocol C which is the one with longest data. So, I don't know it is my usb transmitter problem or it's my receiver problem? Since I don't have the coding for my receiver, I only can check my transmitting part.
 

Thread Starter

ahgan84

Joined Dec 19, 2011
55
I have solved this problem and apparently I overwrite the usb buffer before I transmit out. That's why the receiver will miss.

Now I got another problem.
I test until some point where the HIDTxHandleBusy(USBHandle) is always set, means the usb always busy and my usb can't transmit anymore. Do you know what cause this? How do I clear it so that I can transmit again?
 
Top