Lpc4337 USB1 host: problem sending 64 bytes to usb full speed device

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lpc4337 USB1 host: problem sending 64 bytes to usb full speed device

589 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by PeterZos on Thu Jun 11 00:45:43 MST 2015
I am using LPCUSBLib from LPCOpen v2.16 on lpc4337 to communicate with usb modem device.
USB1 is properly configured and the usb modem is enumerated as full speed device.
After configuring the bulk in and bulk out pipe i can communicate with modem - send AT command to modem and receive response,
make an http request through modem's tcp stack and receive response.
The problem arise when I want to send exactly 64 (128,192,..) bytes to modem.
In that case it looks that modem receive it after sending the next byte.

Pseudocode:
if (HcdGetPipeStatus(PipeInfo[corenum][pipeselected[corenum]].PipeHandle) == HCD_STATUS_OK)
{
fill the buffer with 64 bytes
HcdDataTransfer(PipeInfo[corenum][pipeselected[corenum]].PipeHandle,
PipeInfo[corenum][pipeselected[corenum]].Buffer,
PipeInfo[corenum][pipeselected[corenum]].ByteTransfered,
NULL /* FIXME &PipeInfo[pipeselected].ByteTransfered*/);
PipeInfo[corenum][pipeselected[corenum]].StartIdx = PipeInfo[corenum][pipeselected[corenum]].ByteTransfered = 0;
}
As a result I get the HcdIrqHandler called which in turn calls AsyncScheduleIsr where the status of the respective iTD is changed to OK


I know that on full speed device the MaxPacketSize is exactly 64 byte.
Should i send zero-length packet in case transfer is an integer multiple of MaxPacketSize?
How to send ZLP? The HcdDataTransfer function checks for zero length transfer and returns

if ((buffer == NULL) || (length == 0)) {
ASSERT_STATUS_OK_MESSAGE(HCD_STATUS_PARAMETER_INVALID, "Data Buffer is NULL or Transfer Length is 0");
}

In case I ignore the above if statement, iTD stays queued forever

Any suggestion how to send packet that are integer multiple of MaxPacketSize or how to send ZLP packet will be appreciated

Regards
Labels (1)
0 Kudos
1 Reply

537 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Phil P on Fri Oct 23 03:45:32 MST 2015
I'm having exactly the same problem. If I send less than 64 bytes it's fine, but if I send more then the first 64 bytes disappears. If I send exactly 64 bytes, then the host only receives a zero length packet. I have a library version of USB from Keil - have built and tested this and it works for multiple packets. It uses DMA. My code doesn't. Could this be the problem? As far as I can tell though, once I have sent the validate buffer command, the hardware should be sending the data to the host on the next frame. Yet it doesn't happen when the packet is full. Very frustrating. Anyone out there have any ideas?
0 Kudos