STM32 serial port basics learning

serial/parallel communication

Serial communication: Data is transmitted bit by bit sequentially.
insert image description here
Parallel communication: Bits of data are transmitted simultaneously over multiple wires.
insert image description here
Compared

  • Transmission rate: lower for serial communication and higher for parallel communication.
  • Anti-interference ability: the serial communication is strong, and the parallel communication is weak.
  • Communication distance: serial communication is longer and parallel communication is shorter.
  • IO resource occupation: less serial communication and more parallel communication.
  • Cost: lower for serial communication, higher for parallel communication.

Simplex/half duplex/full duplex communication

Simplex Communication: Data can only be transmitted in one direction. (similar to a radio station)
insert image description here

Half-duplex communication: Data can be transmitted in both directions, but it needs to be time-shared.
insert image description here

Full-duplex communication: Data can be transmitted in both directions at the same time.
insert image description here

synchronous/asynchronous communication

insert image description here
Synchronous communication: share the same clock signal.
Asynchronous communication: There is no clock signal, and some synchronous signals such as start bit and stop bit are added to the data signal.

baud rate

Bit rate: the number of bits transmitted per second, in bit/s
Baud rate: the number of symbols transmitted per second, in Baud

Bit rate = baud rate * log2 M , M represents the amount of information carried by each symbol.
In the binary system, the baud rate is numerically equal to the bit rate.

Common serial communication interface

  • UART (Universal Asynchronous Transceiver): Interface pins: TXD (transmitter), RXD (receiver), GND (common ground); data synchronization method: asynchronous communication; data transmission direction: full duplex.
  • 1-wire: interface pin: DQ: sending/receiving end; data synchronization method: asynchronous communication; data transmission direction: half-duplex.
  • IIC: Interface pin: SCL: synchronous clock, SDA: data input/output; data synchronization method: synchronous communication; data transmission direction: half-duplex.
  • SPI: interface pin: SCK: synchronous clock, MISO: master input, slave output, MOSI: master output, slave input, CS: chip select signal; data synchronization method: synchronous communication; data transmission direction: full duplex.
    insert image description here
    Serial port: serial communication interface: an interface for bit-by-bit sending and receiving. Such as: RS-232/422/485, etc.

Comparison of RS-232 level and COMS/TTL level

  • RS-232 level: logic 1: -15V–3V, logic 0: +3V–+15v
  • CMOS level (3.3V): logic 1: 3.3V, logic 0: 0V (STM32)
  • TTL level (5V): logic 1:5V, logic 0:0V

Therefore: CMOS/TTL level cannot directly exchange information with RS-232 level.

TXD and RXD between two devices must be cross-connected for normal communication.

STM32 serial port communicates with computer USB port

insert image description here

Guess you like

Origin blog.csdn.net/Caramel_biscuit/article/details/131951716