cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host CDC example for STM32407G Discovery board?

Pilot B
Associate II
Posted on April 11, 2018 at 06:13

Hello everyone,

We have a product uses STM32407 MCU. We want to support USB Host CDC for the product. So we ordered a STM32407G Discovery board. We'd like to make USB Host CDC working on the evaluation board first. Basically, we need the Micro-USB to support:

A. The board provide power as the USB Host

B. Support communication with other USB device.

For the power supply, the sample code doesn't support USB Host.

1: So I came cross this page and found some samples:

https://my.st.com/content/my_st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32-standard-peripheral-library-expansion/stsw-stm32046.license%3d1522336640144.html

 

We use IAR, so I found this: STM32_USB-Host-Device_Lib_V2.2.0\Project\USB_Host_Examples\CDC\EWARM

But there is no power from the USB port. I figured we need to use PC0 instead of PH5, so we changed the GPIO definition:

#define HOST_POWERSW_PORT_RCC RCC_AHB1Periph_GPIOC

#define HOST_POWERSW_PORT GPIOC

#define HOST_POWERSW_VBUS GPIO_Pin_0

We also have to disable LCD stuff as there is no LCD on the eval board. But there is still no power. Does anyone know how to get it work?

2. Then I kept searching and found: STM32Cube_FW_F2_V1.7.0\Projects\STM322xG_EVAL\Applications\USB_Host\CDC_Standalone\EWARM

This is CubeMX. I found usbh_conf.c:

HAL_GPIO_WritePin(GPIOH, GPIO_PIN_5, GPIO_PIN_RESET);

And changed it to:

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_0, GPIO_PIN_RESET);

However there is still power from USB port. Does anyone know how to git it to work?

Thanks everyone!

3 REPLIES 3
Posted on April 11, 2018 at 08:30

There is a mass-storage host (USB FLASH drive) for the STM32F4-DISCO

STM32F4-Discovery_FW_V1.1.0\Project\FW_upgrade

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 11, 2018 at 17:47

Hi Clive One,

Thank you very much. I tried the firmware upgrade sample. It works - the board provides power at ~4.62V.

But that is based on USB MSC class. It'll be great if there is USB Host CDC example. Does anyone know if there is any USB Host CDC example for Discovery board?

Thanks.

Posted on April 11, 2018 at 17:53

>>But that is based on USB MSC class.

Understood, it was provided as a working reference point to act as a sanity check. Pretty sure it was based off one of the host libraries, and should provide specific pin usage that can be ported into examples for other board.

I'm sure there are commercial USB Stack vendors that have packaged solutions.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..