USB CDC ACM how to do flow control for RX data - nrf5340

Hello,

 

    I am having an esp32 connected to nrf5340 and I am doing firmware update for the esp32 by bypassing the UART of esp32 via the USB CDC ACM of nrf5340.

So basically esp32 is connected to nrf5340 via UART and the usb of nrf5340 is connected to computer. 

When I get any data in ACM I am writing it to esp32 via uart and vice versa. 

But I am not able to control the in-flow of data via USB ACM and overflow is happening. 

I need to control the flow of data from computer to nrf5340 via USB ACM, how can I do it ?

I couldn't find any CTS macro.

Parents Reply Children
  • Hi again,

    vinodsdw said:

    So are you suggesting to skip reading from fifo inside the irq ?

    If so, the IRQ will git again and again

    At least for test I am suggesting to skip reading from fifo inside the irq yes.

    Looking at the implementation I am not sure the IRQ will trigger again and again, are you sure of this? Have you tried it?

    Kenneth

  • Hello,

       I foud the real issue. 

    When I am trying to send more bytes (more than 500 bytes)  from PC to the device via USB, then the device is getting stuck. I am trying the same exapmle of echo. From PC I am sending using pyserial and if I decrease the single packet size to around 300bytes, it is working non-stop without any issue. If I increase  to 400 it starts getting stuck very fast with in few ping-pong.

  • Can you try to increase the buffer sizes? 

    For instance try to increase RING_BUF_SIZE in main.c and/or increase CDC_ACM_BUFFER_SIZE in cdc_acm.c to see if that affect the problem? I can see that CDC_ACM_BUFFER_SIZE is by default set to CONFIG_CDC_ACM_BULK_EP_MPS, but try to instead set CDC_ACM_BUFFER_SIZE to a larger value.

    Kenneth

Related