USB CDC Bulk IN Endpoint Freeze

1.8k views Asked by At

I am using LPC2368 to communicate with PC using USB CDC. When PC sends the command to LPC over Bulk Out End Point 2,LPC2368 recives 4104 bytes from UART which is sent to PC over USB CDC Bulk IN Endpoint 2.

At PC,this data is considered to be coming form virtual com port,enabling me to see the data (sent to PC) over hypertermial.

There are some commands to which response is less than 64bytes.

After sending command to get these 4104bytes,the 4014 bytes are successfully received from UART and sent in for loop(for in bulk transmission only 64 bytes can be sent in one go) to PC.

Now,if any command be sent after receiving the 4104 bytes,no response is seen.Only,after sending command twice I get response.

Can anyone guide to resolve this behavior of USB?

1

There are 1 answers

6
Turbo J On

for in bulk transmission only 64 bytes can be sent in one go

Yes, and the connection will "hang" if your last transaction is exactly 64 bytes long. Reason is little known feature of bulk pipes that treats back-to-back 64 byte (max packet size) transactions as as single larger transaction. Any packet smaller than max packet size will finish a transaction.

A fix is simple: If you have no more bytes to transmit after a 64 byte packet, just transmit a zero packet. Yes, that is a packet containing no data bytes.

Most USB2UART example codes do not implement this fix, because the UART is usually not fast enough to fill the fifo to 64 bytes in the first place.