cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 USB "Hello world" example?

PHude.1
Associate III

Hi, i am trying to use USB VCP device on STM32F401. Is there a example available for this? Optimally, if it ends with something like the "Hello World" display in the terminal. My goal is to replace FTDI with internal USB in STM.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
PHude.1
Associate III

Funny final solution:

The driver installation process contains the disappearance of the installer window for relativelly long time.

My computer is more slow and probably more programs was running at installation time...

I presume that was occured something like as:

1. I was start the installation

2. Window was disappear

3. Someone was call me

4. I forgotten that installation

5. I was shutdown the computer and go home

:-)

View solution in original post

17 REPLIES 17
Pavel A.
Evangelist III

Cube F4 package has no VCP examples for 'F401. You can take it from other 'F4 board and adapt to your one.

https://github.com/STMicroelectronics/STM32CubeF4/tree/master/Projects/STM32446E_EVAL/Applications/USB_Device/CDC_Standalone

--pa

PHude.1
Associate III

Thank you,

I am trying to compile it. I found most of the libraries it needed, but i can't find declaration for:

../Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c:963:54: error: 'TIM_DMADelayPulseCplt' undeclared (first use in this function)

No vitaj tu medzi nami!

That function is down below in the same file. The newest version has prototypes to the "internal" functions added to the beginning of the file https://github.com/STMicroelectronics/STM32CubeF4/blob/2f3b26f16559f7af495727a98253067a31182cfc/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c#L221

I'm not going to investigate how did it compile before, I don't use Cube.

JW

PHude.1
Associate III

I don't know in which software this example was created, project was not be simply iportable to the Cube.

This problem I was solved by adding prototype and adding the extern to second problematic file. Some similar prblems I solved. Now, declaration of "GPIO_AF7_USART3" not found. Respectivelly, found many times in the stm32f4xx_hal_gpio_ex.h, but in #ifdef for many other STMs.

Before few years I used LPC11U68, examples (downloaded together with LPC Expresso) can be normally imported, working and containing all, incl. send of "hello world".

Now, for STM32, example found "somewhere", not working and does not contain wait for connect, does not contain send of anything. Only "while(1) {}" afther init. This is depressive.

> I don't know in which software this example was created, project was not be simply iportable to the Cube.

The older examples were written before CubeMX, that's why there's no simple way to import them into CubeMX.

> Now, declaration of "GPIO_AF7_USART3" not found.

There's no USART3 in the 'F401. You have to modify the example.

> examples

The idea is, that you buy a devboard which has the target interface, and then you have an example for it ready. Here, you probably should've go with the 'F446 EVAL - yes I know they are expensive - or the venerable 'F4 DISCO. There's a great deal of compatibility between models within one family.

Contrary to popular belief, USB is far from being simple.

JW

PHude.1
Associate III

Thanks all.

Here are two examples that look functional and can be compiled for F401 on our board

1. https://visualgdb.com/tutorials/arm/stm32/usb/

2. http://stm32f4-discovery.net/2015/08/hal-library-21-multi-purpose-usb-library-for-stm32fxxx/

1 is "click-click and go" ... but Visual GDB not properly working with my ST-link 2 from Aliexpress. I was must use the ST-link utility to load flash.

2 have good documentation, but was more difficult to put into operation. First test "bricked" the board:-) And i was must inject 1,4 MHz to oscillator input to reuse it.

Final problem is some on both examples:

0693W00000AMurAQAT.pngTested on 3 computers with win10. With and without installed STM vcp drivers and all results is identical as this image.

As I've said, USB is not simple.

The best thing to do is to observe enumeration and subsequent requests on the bus, using a dedicated USB bus analyzer, or some of the LA/oscilloscopes which support USB protocol decoding (e.g. the Asix LA offerings).

Do you have implemented the SendEncapsulatedCommand and GetEncapsulatedResponse requests, required as per USB CDC PSTN subclass, for Abstract Control Model? If yes, continue debugging by observing all unhandled class-specific requests which may arrive from the host.

JW

Ons KOOLI
Senior III

Hi PHude.1,

The support of the VCP interface is managed through the ST Virtual COM Port driver available for download from www.st.com. Please make sure that you are using this driver.

Best Regards,

Ons.