Skip to main content
Associate II
Dec 28, 2024 1:13 PM UTC
Solved

Putting two 32-bit words in TxFIFO. How to guarantee USB controller doesn't send only half my data?

If my data is more than one 32-bit word and I have to write it one 32-bit word at a time to the FIFO, is it possible that the USB controller could send just the first 32-bit word? Is there a way to stop that from happening?

Thanks

```
USBx_DFIFO(1) = send.u32[0];
// Is it possible for the USB controller to send just the first 32bit word if timing is right?
USBx_DFIFO(1) = send.u32[1];

```

This topic has been closed for replies.
gbm
gbmBest answer
Super User
Dec 28, 2024 5:57 PM UTC

The USB device controller will always send the programmed number of bytes. There are two very different kinds of USB periperal in various STM32. With the simpler one, you prepare data first, then trigger the transmission. With OTG, you first setup the transfer then load data to FIFO, but the transfer doesn't start until the full packet data is loaded. So no, USB device will not start sending anything until you write the declared amount of data.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

5 replies

Associate II
Dec 28, 2024 1:26 PM UTC

Context:

HID device
Interrupt Transfer
6 byte report

gbm
gbmBest answer
Super User
Dec 28, 2024 5:57 PM UTC

The USB device controller will always send the programmed number of bytes. There are two very different kinds of USB periperal in various STM32. With the simpler one, you prepare data first, then trigger the transmission. With OTG, you first setup the transfer then load data to FIFO, but the transfer doesn't start until the full packet data is loaded. So no, USB device will not start sending anything until you write the declared amount of data.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Associate II
Jan 5, 2025 10:42 PM UTC

Thank you for the awesome reply. This makes sense.

Cheers