Skip to main content
Associate II
December 28, 2024
Solved

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

  • December 28, 2024
  • 2 replies
  • 737 views

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];

```

Best answer by gbm

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.

2 replies

Associate II
December 28, 2024

Context:

HID device
Interrupt Transfer
6 byte report

gbm
gbmBest answer
Lead III
December 28, 2024

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
January 5, 2025

Thank you for the awesome reply. This makes sense.

Cheers