0
\$\begingroup\$

Considering STM32 Nucleo Boards, implementing a communication by serial port with a computer is a matter of using UART on the Nucleo Board and connecting it to the computer via USB, where you emulate serial with PuTTY.

I guess that the convertor between UART and USB in this case is implemented in an ST-Link utility embedded on standard Nucleo Boards.

Now, I am planning to build a custom board utilizing the STM32 chipset and I want to have as much of the similar functionality described above as possible - connecting my PCB with a USB to a computer and communicating via UART.

Reading some older posts on this site, and observing the implementation of UART to USB interface on Arduino and ESP32, I get the basic idea of how to do it.

However, I still have some questions regarding this topic.

  1. There are plenty of ICs realizing USB to UART conversion. What are the selection criteria? Are there some significant differences I should be aware of?
  2. Once I finish my board, assemble it, and power it, will my board be communicating via UART with the computer as I described above (i. e. after setting up a PuTTY terminal, or using a function in MATLAB)? Or do I still need some drivers or some additional programming on the computer side?
  3. Most of the ICs have CTS and RTS signals. This is probably explained in datasheets, but do I need to route them if I am not planning some advanced communication and just need to occasionally send data to/from PC?
  4. Would be a program written for Nucleo directly transferable to my custom board (after setting all required peripheries, clocks, etc.)
\$\endgroup\$
6
  • \$\begingroup\$ Is there a reason why you can't just buy a premade RS-232 to USB converter? Why must you have detailed controlled of that design? \$\endgroup\$
    – Lundin
    Commented Apr 17 at 12:46
  • \$\begingroup\$ My application will be powered from the USB. I am not sure if this is possible from RS-232. And I also consider this a possibility for learning. \$\endgroup\$ Commented Apr 17 at 12:58
  • \$\begingroup\$ @HumphreyAppleby Which STM32 model you will be using? If it already contains USB interface and can be directly connected with USB, there is no point using a USB to serial chip. \$\endgroup\$
    – Justme
    Commented Apr 17 at 13:08
  • \$\begingroup\$ It is STM32F401RET6. It does have a USB. It is possible. However, I still would like to know the answer to my question. Also, I lack experience in the utilization of USB on STM32 and I cannot debug the code just with Nucleo as in the case of UART. \$\endgroup\$ Commented Apr 17 at 13:17
  • \$\begingroup\$ I'm sure there are converters with a power pin on them. I recall that some non-standard RS232 solution with pin 9 for supply was common back when I still used UART for stuff like this (nowadays preferring CAN). \$\endgroup\$
    – Lundin
    Commented Apr 17 at 13:30

1 Answer 1

0
\$\begingroup\$

First of all, if you want same functionality as with a Nucleo, please understand that the embedded ST-Link provides a SWD debug interface in addition to UART. You can't copy that feature. If you simply implement an USB to UART interface, you only have UART.

  1. There are plenty of ICs to choose from. You can choose them based on their price, availability, maximum bit rate speed or other features you desire, such as large enough buffer size to be capable of continuous communication at high speed without loss of data. Some cheap chips are garbage that barely work and other chips are known reliable, but you have to understand that before you end up having a working irtual COM port in Windows (or virtual TTY in Linux), your OS must have a driver that can communicate with the USB chip and provide the virtual COM port. Part of the problems are in the chips and part of the problem in the USB drivers for these chips.

  2. It will function if hardware is designed properly and if your OS already has a driver for the USB chip, or if Windows can fetch the driver automatically when plugged in the first time. In some cases you may need to install the USB chip driver manually.

  3. For basic stuff at slow speeds you don't need RTS/CTS. Some STM32 chips have faulty UART hardware handshaking that fails to work anyway, so in some cases you need to do RTS/CTS handshake in software if you need it. You can connect the wires and decide later if you want to use them for something. They could also be used to put the MCU into bootloader mode for uploading firmware from PC automatically.

  4. Yes if you used same UART pins and clock crystal speed etc in your hardware, the same firmware will work on Nucleo and your custom board.

Having said that, it is a bit weird to add an external USB to UART chip, since the MCU supports USB directly. Most likely you spend more time drawing the USB-UART chipset in the design, than clicking mouse in CubeIDE to include HAL with USB HID UART functionality and pregenerate transmit and receive hooks for you.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you. My only concern with the USB is the degraded debugging capability. With UART, I can try my program with Nucleo and determine the problem more easily. But I will consider the USB as well. My only last question is if you can recommend some UART to USB interface. \$\endgroup\$ Commented Apr 18 at 9:16
  • 1
    \$\begingroup\$ @HumphreyAppleby If you want better debugging, you need JTAG/SWD, you should include it anyway, and you can debug with the STLINK on Nucleo or buy a separate STLINK. I understand a real UART for lightweight debugging or console is useful, but it can simply be a pin header where you connect with an adapter cable, so you don't need to implement an USB debug UART in hardware only for debugging. And suggesting specific chip to buy or chip vendor is off-topic. \$\endgroup\$
    – Justme
    Commented Apr 18 at 10:34

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.