4
\$\begingroup\$

I'm looking at the ATMega328p data sheet, and an Arduino Pin diagram, trying to determine if the chip can support three UART connections. I see that PD0 and PD1 are "USART" In and Out. So does that mean the other 10 or so Digital pins can be used for "UART" communications?

I have a need to connect three UART devices through the ATMega chip. The ATMega will forward traffic between two of the devices at a time, depending on which mode it's in.

\$\endgroup\$
2
  • \$\begingroup\$ So non of the Arduenos supports 3 UART ? what about Embed instead of arduino? ok if i Use SPI, do i still need to use the Tx and Rx pin or no need then ?? \$\endgroup\$
    – user15514
    Commented Oct 23, 2012 at 14:36
  • \$\begingroup\$ You should seriously consider using a different chip. While there are workarounds you won't pay much if anything more for a part with 3 hardware UARTs. \$\endgroup\$ Commented Dec 14, 2015 at 14:05

5 Answers 5

3
\$\begingroup\$

If you don't have enough hardware serial ports, you can use other IO pins for serial under software control. But, don't expect to get 115200bps...

http://arduiniana.org/libraries/NewSoftSerial/

\$\endgroup\$
1
  • \$\begingroup\$ I wouldn't use SoftwareSerial for fast stuff / important data as well, but the documentation says "It is possible to have multiple software serial ports with speeds up to 115200 bps". Do you think they're just wrong? \$\endgroup\$ Commented Sep 11, 2016 at 15:25
3
\$\begingroup\$

It is true - only one serial port on the ATMega 328. You can do what the others suggested and use software-serial or you can use a multiplexer if you don't need your serial ports to be always on. Sparkfun has one that can be used for 3.3V here: http://www.sparkfun.com/commerce/product_info.php?products_id=8970

Basically, if there isn't constant traffic, especially if you only need to send messages or you will only receive one response for one command then you can use the multiplexer. Just switch to the device you want, send commands, wait for response, then switch to another device.

\$\endgroup\$
3
\$\begingroup\$

There is only one UART on the 328P. If your bandwidth is low you can do software emulation of a UART with some of the other digital pins. There is an Arduino library called NewSoftSerial that enables this functionality.

\$\endgroup\$
1
\$\begingroup\$

I'm new to SBC development, coming from Software Development, but you may want to look into the ATmega 2560 which i believe has 4 UARTs

\$\endgroup\$
1
\$\begingroup\$

You can add a dual UART with SPI or I2C interface. NXP makes one that I've used on boards. Around $4 from Digikey, it's cheaper than jumping up to a $12 Atmega2560 for a design, and offers more data buffering. https://www.nxp.com/products/analog/signal-chain/bridges/om6273-sc16is752-762-spi-ic-to-dual-uart-irda-gpio:OM6273?lang=en&lang_cd=en&

\$\endgroup\$

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.