RS232 is probably one of the oldest serial interface around (maybe when lab equipments were using GPIB interfaces?)
Originally it needed 3 wires, a TX transmit line, a RX receive line and the Ground reference.
Long time ago, the signals were voltage boosted to get through long cables (MAX232 transceivers)
Then as RS232 became the de facto standard, the MAX232 voltage booster was replaced by a USB translation (FTDI adapters) and seen from computers as VCOM (virtual com port). A popular handy console/terminal interface on PC is called Teraterm.
Now looking at STM32 here are some general info to keep in mind:
There are 2 peripherals available. UART and USART
UART is the simplest one, RX and TX is available
USART is the big brother one: Flow Control Signals are also available (DTS and RTS) plus an optional CK clock signal.
Some USART can talk to SIM chip, then CK and TX will be the 2 signals needed on top of GPIOs.
When choosing a UART, keep in mind of these things:
- The baudrate depends on the chosen clock source. If the clock source is +/-10% so will be the baudrate. As clocks are not shared between the two talking devices, beware... or share the same MCU clock (see MCO)
- Some UART are supported as bootloader... if you need this. Remember that bootloader required EVEN parity bit.
- Signal naming as RX/TX will make you right into Murphy's law: If the two devices don't talk it's probably because the two signals must be crossed....
- LPUART in some STM32 allows possibility to wakeup a clock stopped and sleeping core upon receiving a byte.
- To get started with UART, advice is to use RX as interrupt (without DMA) and TX as polling mode.
- Typical application are:
==> Talk to PC with USB bridge ==> Mostly console, terminal, string exchanges
==> Talk to RF module (WiFi/BT/GPS/Cellular... modules) ==> AT commands strings
RX as interrupt : In the interrupt, when receiving a char, checking for header or end of string character or checksum can be done immediately, then raise a flag which will tell the main loop user code to grab the message then clear the flag.
TX as polling: Most communicatio will be through a "printf" string formatting which requires building a string char by char to be sent. As sending a char to UART takes time, send a printf char as soon as it is computed. (this is usually done in the main loop)
There will be many various ways to use UART and various modes, above one is the one mostly encountered so far.
Hope these few lines will be handy and save time.