cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7, HAL CDC

Traud.Jason
Associate II
Posted on September 26, 2016 at 23:52

I'm looking at bringing up a VCP on an STM32F7 using the Nulceo-F746ZG development board.

Now, after running the CubeMX tools it seems all the magic is happening in the CDC_Receive_FS and CDC_Transmit_FS functions in the generated usbd_cdc_if.c file. 

Just to be sure that this basic example is working, I added ''CDC_Transmit_FS(Buf, *Len);'' just before the return in CDC_Receive_FS. The purpose is to have a simple loop-back so I can load up a terminal and see the bytes go back and forth. 

Now, when I load up Device Manager, I can see ''STMicroelectronics STLink Virutal COM Port (COM8)''.

When I open a terminal program and target COM8, nothing is returned. 

This method in doing a loop-back should work, right? Or could it be non-functional because a transmit call is in the receive function?
2 REPLIES 2
Walid FTITI_O
Senior II
Posted on October 02, 2016 at 19:00

It would be nice if the CubeMX examples actually were CubeMX examples. They do not use CubeMX generated frameworks.

In any event, your problem is probably on the receive side since ST does not document this well enough for anyone to figure out.

First you should just put a transmit of a string (like Hello World) in a loop with a delay to verify you can output characters. This will probably work. On the input side, you need to manage the input buffer to get any input to process.

I make a couple of small edits to the usbd_if.c file and then include my own usb support file, usb.c and usb.h, which I have attached to this post. Hopefully it will help. It creates a circular buffer on the receive side and enables you to access input from the usb port.

Good luck,

Aaron

________________

Attachments :

usb.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HthR&d=%2Fa%2F0X0000000aVu%2FFbMe288i1ROoxMmmuIdfgpEte0TN5Ka8XCXuotUrFZ8&asPdf=false

usb.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htqm&d=%2Fa%2F0X0000000aXr%2FGYPOQXVhaEkXwYP.ZpJxLIQNQakFRM6oU9F1p_upvx4&asPdf=false

usbd_cdc_if.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Htqd&d=%2Fa%2F0X0000000aXo%2FkFVkyCaL6mCl4FXSO2_g6._e4egUJSW1fh5OmA8L58c&asPdf=false