0
\$\begingroup\$

I will keep it short and clean, if it won't be enough please let me know and add more details.

When using an Arduino UNO, a serial communication can be achieved by the same USB connection which is also used to load the code or power the board.

But when using another board for ex. stm32f4-disc, I also power the board and send the code into the board via a USB port on my board. However to get a serial communication between pc and board, I specify some pins as UART Tx/Rx and use a TTL-USB converter.

So why using the USB port on Arduino UNO for serial communication is possible while it is not the case with STM32F4-DISC?

\$\endgroup\$
  • 2
    \$\begingroup\$ The later Nucleo boards have virtual serial passthrough on the USB programmer port. \$\endgroup\$ – Chris Stratton Jul 28 at 12:53
4
\$\begingroup\$

In both boards, communication between the PC and the microcontroller is mediated by another microcontroller.

On the Arduino board, communication between the target micro and the interface micro happens through the serial port of the target, while on ST boards communication happens through SWD interface.

ST used SWD interface because it allows for much more sophisticated control and debugging, while the serial port is somewhat limited on that sense.

When you are not programming the target, on Arduino boards, the serial interface is free to be used as is; the interface chip is seen on PC side as VCP (Virtual COM Port), so the PC thinks it is connected to a serial interface, and sends (and expects) serial signals, that are relayed directly to the target micro. This is not possible through SWD though.

While you do not specify the exact discovery board you have, most if not all of the target MCUs of the STM32F4 series have an onboard USB controller, that can emulate VCP with the ST software stack. If there's a second USB on your board, usually "USER USB", odds are you can use that one, but you will need to use (and understand) the software stack, at least to some extent.

\$\endgroup\$
  • \$\begingroup\$ F407G-DISC1 to be exact, and thanks for the asnwer. \$\endgroup\$ – muyustan Jul 28 at 9:51
  • \$\begingroup\$ Actually on an Arduino the interface chip is always in a passthrough mode; during programming one is talking to a bootloader program on the target chip via the same serial interface. STM32 parts have a bootloader, in fact a permanent one, but it does not offer the debug capabilities which SWD does. Later Nucleo boards support virtual serial as well as SWD via the programming USB; the F4 discovery was designed much earlier in the history of the product line. \$\endgroup\$ – Chris Stratton Jul 28 at 12:56
  • \$\begingroup\$ @ChrisStratton so with the Nucleo boards you mentioned, Can I use same usb port for debugging and also transmitting/receiving data(for example to be monitored on a serial monitor on PC) ? Also what does the second usb port( the one next to audio port) on f4-discovery board? I google it a bit but could not find. Thanks. \$\endgroup\$ – muyustan Jul 28 at 17:16
  • \$\begingroup\$ That is what I said, yes. And this answer explains the 2nd USB port, however you will find that difficulty to use except in the context of a software stack that does most of the work for you. Your present approach is likely best. \$\endgroup\$ – Chris Stratton Jul 28 at 17:18
  • \$\begingroup\$ Thanks @ChrisStratton for pointing out that the chip is in passthrough mode. What I meant is that the serial link is passed through only when programming is not ongoing, but it can be misleading as it is stated now. I'll fix that up. \$\endgroup\$ – Vladimir Cravero Jul 28 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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