Jump to content
Sign in to follow this  

STM32F4 Discovery TxFIFO usage

Recommended Posts

Dear Devs,


I've been working with the STM32F4 Discovery board for a couple of weeks now. I've successfully used its USB Device library to connect the board into the PC by creating a custom class. In fact I modified a VCP example and made it a custom class. I used LibUSB to generate the host side application using MFC applications. I tried bulk transfers, interrupt transfers, basic setup transfers and they all worked perfectly.


The issue came to me when I tried to make a bulk loop. That is within the firmware I will read the OUT packet and save the data in the Tx buffer and send it back to the host. What I did was, I implemented the 'DCD_EP_Tx' function which is supplied by the 'usb_core.c' within the DataOutStage function. As I understood DCD_EP_Tx enables the endpoint so that the endpoint tx buffer data will be sent to the TxFIFO by the core.


The data out function looks like below,


USB_Rx_Cnt = ((USB_OTG_CORE_HANDLE*)pdev)->dev.out_ep[epnum].xfer_count; 

DataSupply_Buffer[i] = USB_Rx_Buffer[i];

/* Prepare the packet to be send through the IN endpoint
DCD_EP_Tx (pdev, 

  /* Prepare Out endpoint to receive next packet */

In this case when I send the data from the host and if I did not read the data from the host, a strange thing happens. Let's say I send around 10, 64byte packets from the host. Then later when I read from the device, I can get the first five 64bytes packets I sent. In fact, they store 320bytes within the FIFO or something.


But within the 'usb_conf.h' I specify that the Tx1FIFO size should be 128.


My problem is how come the device store 320bytes when I set the TX1FIFO depth to 128? I can provide the whole source code if my explanation of the problem is not clear.


I'm still going through the Reference manual line by line to understand the issue. But still I did not have any luck. So if someone can shed some light on this matter. It will be highly appreciated. I don't need an exact answer, but if you have then I'm damn lucky. I might be searching for the issue in wrong direction. Need some new perception.


Thank you in advance.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this