USB on STM32F407VE_BLACK

Hello everyone,

I am trying to learn how to use my board as a USB device for a project and I tried the USB Serial example, but it failed. Specifically, the “Mocking Blink of Failure” started, taunting me, mocking me.

I looked in my PeripheralNames and PinNames files and noticed that the USB pins seem to be assigned to the correct pins, but when I used Serial pc(USBTX, USBRX); in another program, it sent the text to the serial pins instead of the USB.

Is there anyone out there familiar with the F407VET6 “black” board who can help me make serial communication work on it?

Thanks!

Hello Glyn,

Serial pc(USBTX, USBRX);

on any Mbed board creates connection to Serial (aka USART/UART) pins rather than USB pins. But on the officially supported Mbed boards the USBTX and USBRX pins are then connected to an onboard UART-to-USB converter which has a USB connector on the other end. That is why those Serial/USART pins are called USBTX, USBRX. When you connect that USB connector to the PC a Mbed USB driver running on the PC creates a virtual Serial/USART COM port for the serial communication with the Mbed board over the onboard UART-to-USB converter.

Since the STM32F407VE_BLACK lacks an onboard UART-to-USB converter (one of the reasons why it is not an officially supported Mbed board) you have to use an external one and connect it to the USBTX, USBRX pins:

|------------------------------------------|
| STM32F407VE_BLACK | UART-to-USB converter|
|------------------------------------------|
| USBTX             |         RX           |
| USBRX             |         TX           |
| GND               |         GND          |
|------------------------------------------|

You also have to install a driver for it on the PC to get a virtual Serial COM port for the serial communication.
An example of using an external UART-to-USB converter with a not officially supported Mbed board is here.

In case you have a NUCLEO board you can use its onboard UART-to-USB converter and connect it over the CN3 connector to the STM32F407VE_BLACK’s USBTX, USBRX and GND pins. In order to make it work the SB13 and SB14 solder bridges on the NUCLEO’s board shall be ON and the SB62 and SB63 shall be OFF. To have a virtual COM port for the serial communication you have to install an ST-Link driver to the PC. For more details have a look at the STM32 Nucleo-64 boards User Manual.

In addition, the NUCLEO’s UART-to-USB converter can function also as a programmer and debugger. But to use that functionality you have to connect it also to the STM32F407VE_BLACK’s SWDIO, SWCKL and NRST pins as explained here.

That would certainly explain why it doesn’t work. It has a USB port on it, though. Is that just for power? Supposedly, the D+ and D- pins on the USB connector are connected to PA_12 and PA_11, respectively, according to a schematic I found online.

Thanks.

You are right. The USB mini connector isn’t only for power. As you said the USB DP is connected to PA_12 and the USB DM to PA_11 (as shown here). In addition, the USB DP is also tied over an 1.5k resistor to the +3.3V rail configuring it as a client. This enables to build USB component devices. You can use the USBSerial interface to emulate a serial port over USB. Then you can use this serial port as an extra serial port or as a debug solution. It also communicates between Mbed and a computer.

However, when you’d like to use the USB connector as OTG (On-The-Go) to host (attach) USB devices the 1.5k resistor has to be removed. After that it is possible to:

Hi Zoltan,

Thanks for your help in all of this. I just tried that, altering the PinNames.h file to switch USBTX and RX to PA_12 and PA_11, respectively, and then recompiled, flashed to the device, and hooked it up.

My computer is not detecting a USB device. I’ve tried two known working USB cables. I use an FTTI debugger normally, so I know where my usb serial devices end up on my Mac, but I can’t find the port so I can connect to it. It doesn’t blink at me any more, but I still can’t receive anything from the port.

Any thoughts?

1 Like

I built the USBSerial example without any modification to the PinNames.h file and downloaded it to my STM32F407VE_BLACK board. After connecting it over a USB cable to my Linux box (Ubuntu 18.04) a new /dev/ttyACM1 was detected and worked fine with the gtkterm serial terminal. So it seems there is some issue with the Mbed USB driver on your Mac computer.

Hi Zoltan,

Did you use a custom target? I have a custom target that someone built that’s been working for my GUI and touchscreen as well as my SD card, but I can compile with a standard built-in target if you can tell me which one you used.

I just tried arch_max as a target based on your blog entry and it still won’t work, so I suspect you’re right about the problem being with the Mbed USB driver on my Mac. If you need help testing a fix, I’ll be happy to do that.
Thanks!

Hello Glyn,

I’m sorry for the troubles you are having with the Mbed USB driver. Just for the completeness, I used the SMT32F407VE_BLACK custom target published here by Johannes Stratmann.

That did it! I was using Johannes’ version, but an older one from last November. I downloaded it just now and it works perfectly.

Thank you so much, Zoltan!