cancel
Showing results for 
Search instead for 
Did you mean: 

Data transfer to PC with USB CDC connection (STM32F407VGT6)

ildong
Associate

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?

1 REPLY 1
Pavel A.
Super User

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