cancel
Showing results for 
Search instead for 
Did you mean: 

Help deciphering the STM32F072 USB CDC example

I've got the USB CDC VCOM standalone example compiled and running from https://github.com/STMicroelectronics/STM32CubeF0/tree/master/Projects/STM32072B_EVAL/Applications/USB_Device/CDC_Standalone

The documentation has some noteable gaps, some of which would be obvious if the CubeMX project file were available.

The example is a "USB to UART bridge" application, which is not really how most use would use the STM32F072 as a USB CDC end point. Certainly I want to parse the incoming characters to make my system do something. The example just plumbs bytes to a UART, and the way the code is structured there's no visibility of execution flow. What I've discovered is:

1. The 'UART' plumbed to the USB VCP is USART2, based on the fact that it's the only one enabled.

2. USART2 RXD and TXD aren't routed to any pins, PD6 and PD5 don't count as they don't exist on 64 pin package.

12 REPLIES 12
Pavel A.
Evangelist III

>After looking at properties in devcie manager I'm wondering what this means.

Windows correctly detected the USB device and the usbser driver claimed it. All this looks good. Is the 206531584246 the "serial number" of your device?

This does not mean so much: as long as the VCP COM port driver is happy - it should work.

BTW:
which Middleware stack do you run? (the "old" STM stuff or the new one with AZURE RTOS and ACM drivers)?

I can look into my project: I have USB VCP UART working on many projects, since years.

Also asking:
Are we talking about a USB VCP UART implemented in MCU FW, used via the USR USB connector?
Or are you talking about the USB VCP UART which is provided via the ST-LINK debgger?

The first one does not need any "real" UART device, all as USB only.
The second on is a VCP UART but on the ST-LINK chip: it is forwarded as a regular UART: here you need a real UART (e.g. UART1, see the schematics).

When it comes to USR USB VCP UART - I can check in my projects where to check if characters come in.
BTW: you can use breakpoints: but during the Enumeration process (when all the descriptors are sent) - it can time out. Later, when you want to see if a character entered on Host Terminal (e.g. TeraTerm) - a breakpoint should work in your MCU FW.

 

The example is 'bare metal' as that's all I want.

Once I have the USB TX and RX working, the intent is to parse command messages from RX, process them and return a response through the TX. The example doesn't do that, it feeds USB RX to a USART TX and the USART RX to the USB TX, turning the STM32F072 into a USB to UART bridge. None of this is to do with the ST-LINK.

I've now checked that the USART is configured correctly by getting the code to explicitly send a test message and I can see that on the 'scope on the appropriate GPIO pin.