This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840 USB CDC strange problem on Windows 10

Hi,

I am working on a project in which I use the USB_CDC_ACM profile. I have mainly taken the example you provide and add the rest of my code.

Everything is working fine, USB is detected, data is being sent to Host... but I see a strange problem when I connect the Nordic board to a PC with Windows 10 (no test it on other Windows versions).

When I want to send data from Nordic to the host I use this:

app_usbd_cdc_acm_write(&m_app_cdc_acm, tx_data, size);

Where size = NRF_DRV_USBD_EPSIZE, 64. 

I set the size to 64 to maximize the data transaction.

In theory, everything is working as expected, but the problem I see on Windows 10 is that Windows does not receive any data until I send 4096 bytes. When I call 64 times the app_usbd_cdc_acm_write function (64*64 = 4096), then, Windows receives all the data (no data loss).

I tested the same code on a Raspberry pi and I am not having the same issue.

Other funny information is that if I set the size < 64, then, Windows is able to read the data properly (no delay and no buffering).

Please, have you noticed that before and you know a possible solution?

Thanks.

JuanFran

  • In theory, everything is working as expected, but the problem I see on Windows 10 is that Windows does not receive any data until I send 4096 bytes.

    That is actually expected behaviour for USB bulk endpoints, and stated as such in the USB 2.0 spec.

    In order to receive less than 4096 bytes, the last packet must be smaller than 64 bytes. USB also allows for zero byte packets, which can be used to send any integer multiple of 64 bytes as one transaction.

    Note that most CDC example implementations omit this zero packet handling for simplicity.

    I tested the same code on a Raspberry pi and I am not having the same issue.

    Linux should behave roughly similar, but I have not tested USB CDC there much -  was rather using LibUSB directly.

Related