AnsweredAssumed Answered

USB FS TxFIFO problem

Question asked by nelup on Aug 28, 2014
Latest reply on Sep 29, 2014 by nelup
Hello,

I tested STM VCP example on STM32F4-DISCOVERY kit and after solving some code problems (permanent emptyfifo interrupt, size of USB_MAX_STR_DESC_SIZ, ZLP), I got transmission speed cca 500 kB/s from USB device to PC. But I would like to use simple USB bulk communication without the VCP and I would like to get maximal FS speed (max. speed = USB interface is well written).

I would like to reach 1024 kB/s and USB device should transmit 1024 bytes (16 packets of 64B) during 1 ms frame through TxFIFO. This possibility USB FS is written in reference manual (... OTG_FS core is able to fill in the 1.25 Kbyte RAM buffer very efficiently ...). I created code derived from VCP and HID demo. The code sends a data block every second through endpoint IN EP1 and monitors USB interrupts and rotines. Data is read by application using libusb. Communication is working, but transmission is not full efficient. I get following behavior for below settings:

Here is explanatory text:
f = SOF interrupt
[x,y] = x-length, y-packets by USB_OTG_EPStartXfer()
[0,1] = null packet by USB_OTG_EPStartXfer()
i6 = In TxFIFOEmpty interrupt
i1 = In TX complete interrupt
(x...y) = monitoring of DCD_WriteEmptyTxFifo(), x=begin fifo available space, y=final fifo available space, .=calling of USB_OTG_WritePacket()

A) sending 512B, TX1_FIFO_FS_SIZE=128 -> 128*4=512B=8packets*64
fff[512:8]i6(128.......0)i6(64.48)fi1[0:1]i1fff

B) sending 512B, TX1_FIFO_FS_SIZE=160 -> 160*4=640B=10packets*64
fff[512:8]i6(160.......0)i6(80.64)_i1[0:1]fi1ff

C) sending 512B, TX1_FIFO_FS_SIZE=256 -> 256*4=1024B=16packets*64
fff[512:8]i6(256.......0)i6(160.0)i1[0:1]i1fff

D) sending 1024B, TX1_FIFO_FS_SIZE=128 -> 128*4=512B=8packets*64
fff[1024:16]i6(128.......0)i6(64...0)i6(64...0)fi6(64...0)i1[0:1]i1fff

E) sending 1024B, TX1_FIFO_FS_SIZE=256 -> 256*4=1024B=16packets*64
fff[1024:16]i6(256.......0)i6(160.0)i6(160.0)i6(160.0)i6(160.0)i6(160.0)i6(160.0)i6(160.0)i6(160.0)fff
usb stop working

It is noticeable that when trying to write 512 bytes into TxFIFO where there is space for 512 bytes or more, only 7packets*64=448 bytes is written (after 7th packet there is zero space available). I didn't find limit for EP1 TxFifo size in manual, only there is a note in chapter Device programming model about 3-bit internal core packet counter, which limit max. 8 packets for each FIFO. So, I am not able to write 8 packets less so16 packets in fifo. Because of this limitation I can't reach 1024B during 1 ms interruption.

When I try to send more than 512 bytes by TxFifo with space over 512 bytes, USB FS communication stops working.

I would like to ask if there is possibility to transmit 1.25kB during 1 ms as written on USB FS and how? Maybe I am missing some settings. I would be grateful for any comment.

Nelup

Outcomes