arduino 多串口 Serial avr

SoftwareSerial:使用** PCI (Pin Change Interrupt) 中断,可以使用listen()**切换多个软件(模拟)串口,但是速率不能过高,RX接收不正确
参考:

Serial Port Options

HardwareSerial – Best performance. Always use this first, if available! Teensy and Teensy++ have one HardwareSerial port which is available (not used for uploading or the Arduino Serial Monitor). Arduino Mega has 3 extra HardwareSerial ports. Arduino Uno has none.
AltSoftSerial – Can simultaneously transmit and receive. Minimal interference with simultaneous use of HardwareSerial and other libraries. Consumes a 16 bit timer (and will not work with any libraries which need that timer) and disables some PWM pins. Can be sensitive to interrupt usage by other libraries.
SoftwareSerial(formerly “NewSoftSerial”) – Can have multiple instances on almost any pins, but only 1 can be active at a time. Can not simultaneously transmit and receive. Can interfere with other libraries or HardwareSerial if used at slower baud rates. Can be sensitive to interrupt usage by other libraries.
Old SoftwareSerial (SoftwareSerial in Arduino 0023 & earlier) – Very poor performance.

AVR CODE: