cancel
Showing results for 
Search instead for 
Did you mean: 

Why STM32F407VG USB Host CDC sending wrong data?

Pilot B
Associate II
Posted on April 19, 2018 at 09:10

Hi,

I'm working on STM32F407VG board. Try to get USB Host CDC working. I'm able to get enumeration working. The data can be sent to device. But the data is wrong. For example, 'Hello'(

48 65 6C 6C 6F

) is send from Host. But the device received '00 00 00 00 A7'.

Here is the GPIO init:

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_11 | GPIO_Pin_12;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_OTG1_FS) ;

GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_OTG1_FS) ;

GPIO_PinAFConfig(GPIOA,GPIO_PinSource12,GPIO_AF_OTG1_FS) ;

/* Configure ID pin */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;

GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_OTG1_FS) ;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ;

Here is the HSE:

#define HSE_VALUE    ((uint32_t)8000000)

Here are the PLL:

#define PLL_M      8

#define PLL_Q      7

#define PLL_N     336

#define PLL_P     2

I attached the project.

Please help!

Many Thanks! I really appreciate it!

2 REPLIES 2
Khouloud GARSI
Lead II
Posted on April 19, 2018 at 15:58

Hello

kbian

‌,

I'd highly recommend you to refer to 'CDC_Standalone' application under the

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-mcu-packages/stm32cubef4.html

firmware package.

It's is a typical application on how to use the STM32F4xx USB OTG Host peripheral to operate with an USB CDC device application.

You may found it under the path below:

STM32Cube_FW_F4_V1.0\Projects\STM324xG_EVAL\Applications\USB_Host

Khouloud.

Posted on April 19, 2018 at 19:09

Hi Khouloud G,

Thank you so much for your reply.

The reason we're not using CubeMx is because our existing product uses SPL(peripheral library, stm32f4xx_*.c). We just want to add USB Host CDC ability in our existing product. I'm not sure if CubeMx can co-exist with SPL because they are different in architecture wise. 

Is it possible for ST to try to use SPL in the STM32F407VG board to get USB Host CDC working? The fact is, we can send some data by using SPL. However the data is wrong. I think we are really close to succeed in communication. If ST can help look into the issue, it'll be great. It maybe related to PLL, clock or line coding? If you or someone in your team can help, I'd really appreciate it!

Please help!

Thanks again!