Skip to main content
Visitor II
July 20, 2025
Question

Data transfer to PC with USB CDC connection (STM32F407VGT6)

  • July 20, 2025
  • 1 reply
  • 231 views

hello.
I am using STM32F407VGT6 chip and trying to send data to PC with USB CDC function.
But in the below function, the TrySendUsbPacket() function is not executing due to queue full phenomenon.

void EnqueueUsbPacket(const uint8_t* data)
{

uint16_t next_tail = (usb_queue_tail + 1) % USB_QUEUE_SIZE;
if (next_tail == usb_queue_head) {
// Queue full: handle accordingly (error, framedrop, etc.)

return;
}
memcpy((void*)usb_queue[usb_queue_tail].data, data, USB_FRAME_SIZE);
usb_queue_tail = next_tail;
TrySendUsbPacket(); // Add to queue and try to send immediately
}

I've put my full function as an attachment, can anyone tell me why the USB transfer doesn't happen until the queue is full?

    This topic has been closed for replies.

    1 reply

    Super User
    July 20, 2025

    USB transfer cannot happen before the host sends IN requests (and enumerates the device successfully).