Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 4 months ago.
No USB or UART on STM32F407 Discovery
Hi all.
I have a STM32F407VG discovery board, but I'm stuck in getting simple serial communication to work.
Simple code like
Serial pc(USBTX, USBRX); pc.printf("GHello world!");
or
Serial out(PA_9, PA_10); out.printf("Hello world!");
does not work. I have tried on all UARTs on the board, on two boards and on 2 computers.
2 Answers
6 years, 4 months ago.
Which version of the Discovery board do you use. The older editions dont support the Virtual Com Port (VCP) on the ST-Link. Some of the newer edition Discovery boards do provide the mbed compatible UART connection in principle. They are named something like ''STM32 XXX DISC1". However, even for the new boards you need to connect the F407 UART pins for Serial pc (USBTX,USBRX) to the ST-Link part so that pc.printf and printf work. You may attempt a hack as explained here and in the user manual or alternatively use a separate USB-Serial converter (eg FTDI 232) instead.
Hello,
Jenny: Yes, I believe I have the latest version: V2.J31.M21
Win: I use the STM32F407VG-DISC1 board. MB997D D-01. I suppose it is one of the new boards?
posted by 20 Jun 2018Hi Wim Huiskamp, Thanks for your response. I am using the latest board "STM32F407VG - DISC1". Hope that helps!
posted by 20 Jun 2018See updated text above: the new DISC1 boards still need a modification before the USB serial port is operational.
posted by 20 Jun 2018Hi Wim,
Just to make sure that I understand you correctly, In the link you posted above with the explanation to connect pins 12 and 13 on the STLink chip to USART2, the purpose here is to enable communication from the main CPU to the STLink chip and then to a PC console, correct? This is what I would achieve? And I will be able to use Serial pc(PA_2, PA_3); pc.out.printf("Hello world"); to print messages to a PC console?
posted by 21 Jun 2018Hello Kasper, that is correct. The ST-Link functions as a serial-to-USB converter between the target (F407) and the host PC. That is the ST-LINKs second function next to the drag-and-drop programming of the target. The STM Nucleo boards and some of the recent STM Discovery boards already have the correct default wiring for the serial port. The F407 Discovery board is an older type that does not support this feature at all (DISCO version) or only after modifications (DISC1). In case the soldering job needed for the modification is too much of a challenge you can also use an external (FDTI type) serial-to-USB module instead (hardware costs is only a few dollars online).
posted by 21 Jun 20186 years, 4 months ago.
Hi Kasper,
Have you tried using just printf
without the Serial object? For example:
#include "mbed.h" int main() { printf("Hello World!\n\r"); }
Also, please make sure that your serial terminal viewer is set to view your board's serial output with a 9600 baud rate. This is the default baud rate that the Serial object uses.
The answer I provided on this question may help as well: https://os.mbed.com/questions/81577/Unable-to-send-output-to-a-Terminal-Usin/
Also, there is also a new ST-LINK firmware upgrade available for download here: http://www.st.com/en/development-tools/stsw-link007.html
Please let me know if you have any questions!
- Jenny, team Mbed
If this solved your question, please make sure to click the "Thanks" link below!
Hi Jenny,
Yes, I have tried that. I have managed to get signals on UART4 on PA0 and PA1. I used 9600 for all trials. And I updated the firmware :-) But that is by using STM32Duino. I am unable to get it going in mBed, unfortunately.
posted by 20 Jun 2018Hi again Kasper,
The newest ST-LINK firmware was just released today, did you update your firmware again today? http://www.st.com/en/development-tools/stsw-link007.html
Also, please let me know if you see any error messages. Does anything happen at all when you try to compile/flash with Mbed?
- Jenny, team Mbed
posted by 20 Jun 2018