I cannot send more than 63 bytes using MQX USB host example software for CDC.

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

I cannot send more than 63 bytes using MQX USB host example software for CDC.

1,203 Views
paulhunt
Contributor I

I am using the CDC USB Host example in a project. I ran across an issue in which if I try to send 63 bytes or fewer, it will send it. However, if I try to send more than 63 bytes, the stack will not send those out, until it gets another write that is less than 64 bytes again. Then it will send out a large buffer of data, that does not seem coherent. Parts of it seem fine, other parts seem altered.

Using the CDC Uart2USB and USB2Uart example in the MQX directory, I can replicate this issue easily. Does anyone have some ideas as to what may cause this? I have tried stepping through all the way down to the KHCI level and do not see what the issue is.The TR seems set up each time with the correct size and buffer in memory. But it still performs this behavior.

Thank you,

Paul

Labels (1)
0 Kudos
4 Replies

584 Views
paulhunt
Contributor I

The issue I had, had two causes. The first was that the device I was attaching was sending a descriptor that had a max packet size of greater than 64. So, the host would see this and would fail a check and the host code would assume a descriptor max packet size no larger than 64 as its a full speed device (there should be a sanity check in the stack for this). So, I fixed that on the device side. That then left an issue in which I could send any packet except for one that was exactly 64 bytes in size. Ideally, you would send a zero length packet. However, there is a check in code that would discard such a write. So, in the stack I wrote a piece of code that would detect if there was a 64 byte packet being sent, then follow it up with a zero length packet. Again, if I tried to do this at the application level, it would fail sending a zero length packet on a check at the stack level.

0 Kudos

584 Views
jonb
Contributor I

I believe you can have up to 19 packets (64 bytes) per frame with CDC.  It depends upon what hardware you have as to whether it can actually schedule that many packets per frame.  Some micros can only do 1 or 2 packets per frame.  I think the Kinetis stuff can do 16 packets per frame.

The 63 bytes issue sounds to me like some code somewhere is botching the packet scheduling.

0 Kudos

584 Views
jonb
Contributor I

What processor are you using?

0 Kudos

584 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Paul,

CDC uses bulk transfers, and the spec says that the maximum number of bytes you can send in bulk transfers is 64.

Best regards,

Carlos

0 Kudos