Skip to main content
Visitor II
November 24, 2022
Question

STM32L4Q5 I am using the USB interface in Device mode (CDC Virtual Comms Port) and the My_CDC_Receive_FS() interrupt callback. How can exercise flow-control on the incoming USB data to give me time to process it?

  • November 24, 2022
  • 1 reply
  • 507 views

In the callback I buffer the input read by the USBD_CDC_ReceivePacket() call and exit My_CDC_Receive_FS() asap, processing the incoming data in the background

Sometimes, my input buffer fills, & I can't easily make it any larger or empty it any quicker

How can I hold-off the incoming data without upsetting the USB driving code?

(i.e. simply not calling the USBD_CDC_ReceivePacket() fn if my buffer is full is not an option as it seems to close the USB connection / upset the USB driver)?

    This topic has been closed for replies.

    1 reply

    Graduate
    November 24, 2022

    That's exactly how you are supposed to do it. By not calling CDC_ReceivePacket() you may safely delay the incoming data. If there is a problem with your application, it's probably somewhere else.

    Be warned, however, that all USB-related routines, like Transmit and ReceivePacket, must be called from an interrupt service routine of the same priority as USB interrupt or, alternatively, with interrupts being disabled.