# STM32 print via UART without Nucleo/Discovery

I would like for debugging/trace purposes to print texts (preferably via printf but just text is also fine) from an STM32F103C8T6 to a (PC) terminal application.

I noticed that all examples use a Nucleo or Discovery board but I don't have those. I'm using ST Link/V2 and System Workbench (Eclipse).

Does anybody know how to do this or if it is even possible? (I guess so with some USB/RS232 converter maybe).

• You can print the string on any UART lines and use a UART to USB converter to see it on PC terminal. Because a Nucleo/Discovery has a onboard UART/USB converter which does exactly the same thing. – ammar.cma Nov 22 '17 at 10:25
• Check this tool: st.com/en/development-tools/stm-studio-stm32.html A bit better than sending strings. – Bence Kaulics Nov 22 '17 at 11:30
• @BenceKaulics If it works together with Eclipse than it would be very useful. – Michel Keijzers Nov 22 '17 at 11:41
• It is not a plugin but a completely independent tool. – Bence Kaulics Nov 22 '17 at 12:17
• @BenceKaulics I know ... but I cannot e.g. use ST Link Utility together (simulatenously) with Eclipse, probably with that tool I have the same problem. – Michel Keijzers Nov 22 '17 at 12:18

All the STM32F0 that I can think of come with UART hardware – meaning that you just need to write your string to some address, and trigger the transfer.

The knowledge of how to do that can be taken from the Reference Manual of that family (ST Document number RM0008), or just straight from the UART driver within the STM Cube software package.

Electrically, you'll really get a TTL UART – any TTL serial-to-USB converter will do. The Nucleo boards just contain a second microcontroller that plays a USB-to-STLink and USB-to-TTL-UART bridge.

For "easy" debugging, the UART is certainly the least error-prone communications interface in the chip. If you're tempted to directly communicate with the PC: Your MCU comes with a USB2 transceiver. You can, adding a few resistors, directly connect that to your PC, and let it look like a serial adapter itself, just giving you your messages or data! That is, given you have a firmware that handles the USB stack. ST offers a library to do that, and that comes with examples. Be warned though that USB is way more complicated than UART, and if you just want to occasionally print short strings, UART certainly is sufficient. The USB interface allows you to send USB data packets through USB2 Full Speed (that's the 12Mb/s standard) – that can be hell of an advantage if you need e.g. to build something that samples a signal rapidly (that's why I used USB on an ARM the first time) in the long term.

• Thanks for the answer ... I just need some data (I doubt I need 12 MB/s, at least not for now)... I will check further into the TTL serial to USB converter ... will my PC automatically detect it as a com port or should I install a driver to have it visible in a terminal application? – Michel Keijzers Nov 22 '17 at 10:31
• Windows generally comes with drivers installed because this has been around for a while. Use HyperTerminal or PuTTY to open the COM port on the baud rate you set in firmware and you should be able to see the ASCII characters. – ammar.cma Nov 22 '17 at 10:33
• @ammar.cma Thanks ... also I found this learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers/all to install ftdi drivers, so even in case it is not autoamtically I can try that. – Michel Keijzers Nov 22 '17 at 10:34
• @MichelKeijzers It depends on the TTL/USB adapter you get and which chip it uses inside. FTDI is common, but cheap knockoffs come from different vendors and thus different drivers. Although, you shouldn't have a problem with drivers. (tons of online tutorials for that) – ammar.cma Nov 22 '17 at 10:36
• @ammar.cma I have a cheap knockoff probably ... but I will check if it works (when I have time)... it's a 'hobby' project getting out of hand a bit :-) ... but a good way to learn about microprocessors. – Michel Keijzers Nov 22 '17 at 10:49

There is no problem with it. You have few options. The first way is to configure your UART (the process may be very straightforward if you use CubeMX) to send text and then hook-up RX and GND pins of your USB-RS232 to TX and GND pins of your board respectively. Then you can transmit your logs for example with function HAL_Uart_Transmit(). More advanced option is to redirect stdout to that UART. But it will take a lot of effort to configure and run this.