Serial interfaces

These pages are about serial communication normally used between computers and microcontrollers.

It covers

  • bits and bytes

  • hardware based interface (UARTS)

  • software based interface (eg software impl of uart functionallity)

under construction see menu for first pages

Litterature and links

RS-232

Serial connections are often named as RS-232

  • RS232 (Recommended Standard no 232 - from telecomm world) from 1060

  • EIA-232 (Electronic Industries Alliance) sucesor of above from 1969

The signals have following characteristic

  • data line voltage levels [+3V to +15V] (logic 0)

  • data line voltage levels [-3V to -15V] (logic 1)

  • data line idle level same as logic 1

See https://en.wikipedia.org/wiki/RS-232

TTL serial

Same as RS-232 except for data signal levels


NOTE1: many call a TTL serial interfacs for RS-232 - this is pedantic not true
NOTE2: real RS-232 serial lines is very very rare. Its all TTL level serial
  • data line voltage levels 0V (logic 0)

  • data line voltage levels 3.3V or 5V or x.xV (logic 1)

  • data line idle level same as logic 1

Two TTL communicating devices must use same voltage for defining logical 1

If you connect a 3.3V device to a 5V device you might damage the 3.3V device if it is no 5V tolerant on input.

And the 5V device might have level problems so it cant recognice logical 1 (high) which is 3.3V less from the 3.3V device.

Arduino AVR series (uno,mega,…) logic 1 is 5V
ESP32 logic 1 is 3.3V
many stm32 logic 1 is 3.3V
You have to find out


You can use a bidirectional level shifter between a 3.3V and 5V device to ensure proper connectivity.

 

Details

 

Schematics

  • LH High level side high level eg 5V

  • LV Low level side high level eg 3.3V

  • GND two of them one from hig level device and one from low level device

  • LV1,2,3,4 input/output on low level

  • HV …. on high level

  • you need one connection from each line

prices:

  • level shifter with four connections approx 40 dkk

  • one bss138 fet approx 2 dkk

The circuit works with devices from 1.8V to 5V approx