cancel
Showing results for 
Search instead for 
Did you mean: 

USB Device VCP Speed issue in STM32F405

igal
Associate II
Posted on May 30, 2013 at 14:01

Hi,

I use STM32F405RG and the VCP driver from ST. I use USE_USB_OTG_HS,

USE_EMBEDDED_PHY

The changes I made to the ST driver are as followed:

in usbd_conf.h

&sharpifdef USE_USB_OTG_HS

 &sharpdefine CDC_DATA_MAX_PACKET_SIZE       64  /* Endpoint IN & OUT Packet size */

 &sharpdefine CDC_IN_FRAME_INTERVAL          5   /* Number of micro-frames between IN transfers */

 &sharpdefine APP_RX_DATA_SIZE               ((8)*1024) /* Total size of IN buffer:

in usb_conf.h

 &sharpifdef USE_EMBEDDED_PHY

   &sharpdefine USB_OTG_EMBEDDED_PHY_ENABLED

//   &sharpdefine USB_OTG_HS_LOW_PWR_MGMT_SUPPORT

 &sharpendif

Also the change suggested by bil.til

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Yet%20another%20STM32F1057%20USB%20OTG%20driver%20issue%20%28VCP%20device%29&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=1168

I believe it applies to F405 as well.

I send 960 bytes every 3.18msec (using VCP_DataTx) but I keep getting USBD_BUSY in VCP_DataTx.

I'm communicating with PC, I tried using Docklight, AccessPort and my own application in Visual Studio standard COM port (Readfile of winapi)

Any suggestions?

and on a different note, what is ''CDC_IN_FRAME_INTERVAL'' mentioned in usbd_conf.h?

APP_RX_DATA_SIZE*8/MAX_BAUDARATE*1000 should be > CDC_IN_FRAME_INTERVAL*8 */

Many thanks

#maximum-output-speed #usb-vcp
3 REPLIES 3
tsuneo
Senior
Posted on May 30, 2013 at 15:23

> #ifdef USE_USB_OTG_HS

 

> #define CDC_DATA_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */

CDC_DATA_MAX_PACKET_SIZE should be 512 for High-speed (HS), because this macro is used to declare wMaxPacketSize (MPS) of the endpoint descriptors. By the USB2.0 spec, HS bulk endpoint should have 512 bytes MPS. Don't change this value on the original example.

I'm not sure what occurs on your PC host controller for the out-of-spec MPS, because out-of-spec behavior heavily depends on the implementation of the host controller.

> Also the change suggested by bil.til here I believe it applies to F405 as well.

Yah, you may delete ST's bad solution, too, as I pointed out in

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flooded%20empty%20FIFO%20interrupts%20still%20make%20USB%20devices%20crawl

post.

> I send 960 bytes every 3.18msec

You'll get this transfer rate even on OTG_FS, without the external ULPI HS PHY 😉

Tsuneo

igal
Associate II
Posted on June 02, 2013 at 10:28

Thank you for your reply, but as I said, I don't use external ULPI HS PHY. I use HS core with internal PHY (so HS core in full speed). for that reason CDC_DATA_MAX_PACKET_SIZE is 64, if it was 512 it wouldn't work.

So still I don't know why I get USB Busy.

Any ideas?

igal
Associate II
Posted on July 01, 2013 at 11:13

I found the solution:

The Host (PC) asks to check if there is new data every 1ms (frame)

In

usbd_conf.h

CDC_IN_FRAME_INTERVAL

is

5

That means that the driver will check if there is new data every 6 frames (the code is

if (FrameCount++ == CDC_IN_FRAME_INTERVAL)

  )

So the VCP speed is reduce by 6 times (instead of 9Mbps it will be about 1.5Mbps)

I changed

CDC_IN_FRAME_INTERVAL

to

1

and now I get much higher speeds without reaching

USBD_BUSY

in

VCP_DataTx

function (

USBD_BUSY

means I try to write data to the buffer but it is full since the PC didn't take it)

CDC_IN_FRAME_INTERVAL

should be

0

for max speed but causes higher current consumption and I imagine more interrupts, try to put the value that fits your requirements.