Other Parts Discussed in Thread: MSP430F5521
Hi!
I ‘ve been working with the MSP430 USB DEV PACKAGE using HID DATAPIPE interface.
I am using MSP430F5521.
I am having an reception issue (device side) when the data packet is bigger than the report size.
I am using for the reception this function:
WORD hidReceiveDataInBuffer (BYTE* dataBuf, WORD size, BYTE intfNum)
{
WORD bytesInBuf,rxCount;
BYTE* currentPos = dataBuf;
while (bytesInBuf = USBHID_bytesInUSBBuffer(intfNum))
{
if ((WORD)(currentPos - dataBuf + bytesInBuf) <= size){
rxCount = bytesInBuf;
} else {
rxCount = size;
}
USBHID_receiveData(currentPos,rxCount,intfNum);
currentPos += bytesInBuf;
}
return (rxCount);
}
If the packet has less that 64 bytes, this function Works fine. Then, when the host sends a larger packet, the USBHID_bytesInUSBBuffer function returns 0 in the second call, so my resultant data packet is only one report’s size. Then, I try the same (the PC sends the big packet) but with a breakpoint “currentPos += bytesInBuf;” line (after the 1st receiveData). In this case, the USBHID_bytesInUSBBuffer function returns some thing different to 0 (the rest of the packet’s size) and then all the data packet is received.
It seems that I should need a little delay before calling USBHID_bytesInUSBBuffer but I am not sure. Maybe the problems comes from the PC side. I don’t know.
Please help me on this issue.