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

USB dongle nRF52840 USB CDC ACM receiving problem

Hello dear Nordic Semiconductor.
I use one of your creation - nRF52840 USB dongle. I have troubles with using USB CDC ACM.
I add ble stack to gather info about advertisement and wnat to send some data via USB CDC ACM. Sending is okay. But receiving data from pc to usb dongle is not okay. It misses packets. What can be the reason?
Also want to ask if it is possible to use TLSv1.2?

Example of my code that is working:

case APP_USBD_CDC_ACM_USER_EVT_RX_DONE:
{
// bsp_board_led_invert(LED_CDC_ACM_RX);
ret_code_t ret;
m_send_flag = 0;
wr_idx = 0;
memset(m_tx_buffer, 0, NRF_DRV_USBD_EPSIZE);
// NRF_LOG_INFO("Bytes waiting: %d", app_usbd_cdc_acm_bytes_stored(p_cdc_acm));
do
{
/*Get amount of data transfered*/
size_t size = app_usbd_cdc_acm_rx_size(p_cdc_acm);
// NRF_LOG_INFO("RX: size: %lu char: %c", size, m_rx_buffer[0]);
// memcpy(m_tx_buffer, m_rx_buffer, size);
if (size == 1)
{
memcpy(&recv_buf[cnt_idx], &m_rx_buffer[0], 1);
cnt_idx ++;
/* Fetch data until internal buffer is empty */
ret = app_usbd_cdc_acm_read_any(&m_app_cdc_acm,
m_rx_buffer,
size);
}
else
{
memcpy(&recv_buf[cnt_idx], &m_rx_buffer[0], size);
cnt_idx += size;
/* Fetch data until internal buffer is empty */
ret = app_usbd_cdc_acm_read_any(&m_app_cdc_acm,
m_rx_buffer,
size);
}
} while (ret == NRF_SUCCESS);
m_send_flag = 1;
bsp_board_led_invert(LED_CDC_ACM_RX);
// xSemaphoreGiveFromISR(USB_CDC_RX_Mutex, &xUSB_CDC_RXTaskWoken);
// /* If xUSB_CDC_RXTaskWoken was set to true you
// we should yield. The actual macro used here is
// port specific. */
// portYIELD_FROM_ISR( xUSB_CDC_RXTaskWoken );
break;

Parents
  • Hello,

    Please use the "insert" -> "Code" option when you want to attach source code, because this doesn't strip away indents.

    How do you determine that you are missing events? You need to debug your application to see what's going on. Perhaps your application's error handler triggers, and the device reset. But in order to find out, you need to debug the application, or to use the log. The reason I suspect that you haven't done this is that you are using the dongle, which doesn't have a debugger. I suggest that you consider getting your hands on an nRF52840 DK for the development. When you have som software that it working, you can run it on the dongle.

    Best regards,

    Edvin

  • So I debug it. the main question is for me why sometimes I see 64 bytes of packet and sometimes I receive byte by byte

Reply Children
  • When you are debugging, does the event originate from cdc_acm_rx_block_finished() or cdc_acm_endpoint_ev() in app_usbd_cdc_acm.c? Are you always sending the same 64 byte packets?

    What does your log look like? Can you try to enable APP_USBD_CDC_ACM_CONFIG_LOG_ENABLED (set it to one in sdk_config.h) and set APP_USBD_CDC_ACM_CONFIG_LOG_LEVEL to 4?

    Best regards,

    Edvin

Related