4
\$\begingroup\$

I've been searching for this and still haven't found anything about it. This board connects directly to the host PC with a USB bus. Is it possible to emulate a serial port in this case?

\$\endgroup\$

4 Answers 4

0
\$\begingroup\$

This project implements CDC USB serial on the STM32F4 Discovery.

https://www.das-labor.org/trac/browser/microcontroller/src-stm32f4xx/serialUSB

\$\endgroup\$
3
  • \$\begingroup\$ I've tried using this project but with the armcc compiler and it didn't work yet. Windows says it is an invalid USB device. \$\endgroup\$
    – ivarec
    Apr 2, 2012 at 16:53
  • 1
    \$\begingroup\$ Try using usbsnoop to debug the USB messages. \$\endgroup\$ Apr 2, 2012 at 18:49
  • \$\begingroup\$ @TobyJaffey The link got expired! Can you please update the link or explain the key implementation? Thank you! \$\endgroup\$
    – charansai
    Jan 15, 2018 at 12:13
1
\$\begingroup\$

There are two USB connections on the board - the micro USB connector at the top and then the micro A/B connector for the USB On-The-Go support. The first connector is the programming interface - this connects only to the programmer chip and not to the actual target microcontroller. There's no way to use this connection as an emulated serial port.

As for the USB OTG connection I'm less familiar with it but judging by the Wikipedia page on the subject it seems that it's not really meant for that either - USB OTG is focused on acting as a semi-host for peripherals such as thumb drives or bluetooth adapters or something. Just doing a quick Google search yields no serial port emulators and from my assessment of how OTG works my initial reaction is that it won't work.

However, it is perhaps possible that you could configure the OTG device to act as a regular USB device and then code a serial port emulator to reside on the board, but that's a whole development effort on its own. You're best off attaching a cable like this to the UART pins on the board and interfacing through the UART on the microcontroller that way.

\$\endgroup\$
1
\$\begingroup\$

You might want to check out my question (and answer): ST-LINK is serial communication possible? I managed to run serial communication over SWD.

\$\endgroup\$
0
\$\begingroup\$

If there is a way to send serial data from the STM32F4 to the PC thought the programming USB connection, I have not seen how to do it.

I managed to get ( text type ) GPS data to the PC as follows:
(1) Adapt the USART software example for the STM32F4 at "Elia's" website (2) Connect the STM32F4 TX and RX and GND pins to a USB-serial device such as I use for serial communication between the Arduino and PC or the GPS device and PC. (3) Use PuTTY to display the serial data being received at the PC.

This seems to work but it rather annoying. I also cannot make it work in both directions, which I could do with the Arduino and other devices.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.