cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 USB Overflow

mattfox
Associate II
Posted on January 14, 2014 at 21:30

I'm currently using USB for communication between a server and my ST32F373C8.  I'm sending a lot of data back and forth between the two and I believe that I am overflowing the USB PMA before I am able to copy it over to the user space.  I was wondering if anyone knew if there is some overflow protection so that the data is held until there is space in the PMA for my endpoint or if the data is just lost.  Also, I was wondering if there is a way to increase the buffer size for my endpoint so that I don't overflow and lose data.  I read something about double-buffering, but I'm not sure if that's what I want to do or if that is used for something else.

Thanks in advanced for any help!
1 REPLY 1
tsuneo
Senior
Posted on January 15, 2014 at 14:15

For OUT endpoint, received packet (transaction) is kept on the endpoint, until the firmware reads it out. The endpoint returns NAK to host, while the EP is occupied by the last packet. NAKing is USB instrinsic flow control. The host repeats the next packet, while the device is NAKing.

Using this feature, you may prevent overflow of your receive buffer without any data loss.

On STM32_USB-FS-Device_Lib_V4.0.0,

USB_SIL_Read() reads out a packet from the OUT EP.

In most examples in this lib, the ISR of OUT EP (like EP3_OUT_Callback()) calls this reoutine.

It is the cause of buffer overflow - Because, the endpoint interrupt occurs at the host timing, regardless of the buffer condition on your firmware.

You may move USB_SIL_Read() out of the ISR, so that the ISR doesn't overwrite your buffer. The ISR just raise a flag. In your main loop (or on tick timer), your firmware polls this flag to know packet reception, and it reads the packet using USB_SIL_Read(), just when there is room on your buffer.

Tsuneo