0
\$\begingroup\$

I'm building a board where I want to support multiple types of interfaces like RS422/RS485, CAN Bus, RS232 and connect these to my MCU using UART. If I only have one free UART on the MCU, what is the best way I can switch between those different options?

For example I might have a MAX3488AE IC to connect UART for Rs422/RS485 and also maybe an ST202CDR for RS232 communication and also a CAN Transceiver (MAX 14878 maybe). Is there a good/standard way to wire all of these to a single UART RX/TX pair? Then either via firmware using GPIOs to activate some switch IC to switch between those or even a physical switch to let the user do it manually (since likely they won't need all of those). Would it be acceptable for example to just control which of those interface ICs gets VCC and is therefore on, or do I need to switch all the Rx/Tx lines?

The goal is not to use any of these simultaneously but just to allow choice (preferably via firmware by setting GPIO to some switcher) as to which is active.

\$\endgroup\$
4
  • \$\begingroup\$ This is a very open question, depending on what parts you choose there may be many different ways to achieve what you are asking for.. I'm thinking that your peripherals may have enable inputs that you could use to, but again depends... switching off the power most likely wont be the right solution as that will often result in the inputs being tied to the now floating supply through input protection diodes. \$\endgroup\$
    – user173292
    Commented Jan 31, 2021 at 21:33
  • \$\begingroup\$ The least-cost, least board space way to do this is to just choose a microcontroller that has all the peripherals that you need. You are aware that CAN doesn't work through an ordinary UART -- yes? It needs its own logic. The CAN tranceiver you cite is just for the electrical interface -- not for the logic. \$\endgroup\$
    – TimWescott
    Commented Jan 31, 2021 at 21:45
  • \$\begingroup\$ @TimWescott yeah thanks for the CAN note, my MCU actually has CAN controller pins, so those can be dedicated. Probably just need to switch between RS422/485 output and RS232. \$\endgroup\$
    – Fraggle
    Commented Jan 31, 2021 at 22:42
  • \$\begingroup\$ use jumpers to make a selection \$\endgroup\$
    – jsotola
    Commented Feb 1, 2021 at 1:56

2 Answers 2

1
\$\begingroup\$

The worst thing you can do is connect them all in parallel and then leave unused chips unpowered so they will disturb the signal.

Put something like a two channel analog multiplexer there. Or a single digital multiplexer for the RX pin, as TX output from MCU can be connected to all TX inputs of the chips without trouble.

\$\endgroup\$
3
  • \$\begingroup\$ "The worst thing you can do..." yeah lol, I sort of figured that would be a bad idea, but just wanted to check. I will look at some multiplexer options. \$\endgroup\$
    – Fraggle
    Commented Jan 31, 2021 at 21:47
  • \$\begingroup\$ So the tx outs of MCU can all be connected together because MCU knows what it is outting? Also wondering if I need to switch the power to the converter ICs on/off or just leave all on (and suffer whatever quiescent power draw they consume). So the analog multiplexer vs digital multiplexer, I would have assumed digital is preference (unless I'm switching Vcc to the chips on/off). \$\endgroup\$
    – Fraggle
    Commented Feb 7, 2021 at 19:38
  • \$\begingroup\$ Maybe something like this?: i.imgur.com/S9UcaqC.png (not finished but you get the idea) which has a digital multiplexer for the uart signals and an analog multiplexer for the VCC to the other chips (maybe vcc switch is overkill?), @Justme let me know what you think \$\endgroup\$
    – Fraggle
    Commented Feb 7, 2021 at 21:30
0
\$\begingroup\$

For the 485, the MAX348xAE you listed has DE/RE (driver-enable / receiver-enable) pins to tristate them when you are not using the 485 option.

For the 232, you could add tristate buffers, along the lines of 74hc125, between MCU and the RX/TX pins of the 232 interface chip. You may also be able to find a 232 interface chip with built in DE/RE functionality like the MAX348xAE.

Same if you have a 422 interface chip.

For the CAN, per your comment you have dedicated pins, so it is an independent problem from multiplexing the UART.

If using the additional tristate buffers, pick the appropriate logic family for your situation, and arrange pull-ups or pull-down's so that any disabled comm chips are well behaved.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.