Switching UART Routing - Page 1
Forum section: electronics / projects

author: remixed123
author_rank: Regular Contributor
timestamp: August 05, 2015, 04:35:34 am
content: I am looking for opinions regarding a circuit design to get around a limitation.Problem:I am using an MCU that needs to communicate with 2 ICs via UART, but my MCU only has 1 UART.Suggested Solution:Use the same MCU UART and then switch routing between the 2 ICs by using GPIO pins on the MCU and few transistors. (Within the code this is fine, as the 2 processes involved need to occur sequentially)I know what I am suggestion is possible, I am more interested in opinions as to whether this is a common solution and acceptable, and whether it is recommended or not.Also, is a transistor a good choice for this, or should I be switching the routing using a different mechanism?

author: Mr.B
author_rank: Unknown
timestamp: August 05, 2015, 04:55:53 am
content: I have done exactly what you are wanting to do before.74HC241 Octal Buffer.Datasheet below.

author: Psi
author_rank: Super Contributor
timestamp: August 05, 2015, 06:20:47 am
content: I would just make a software uart for the slower/less used device.Trying to share a bus can make code get complex. You have to write a gateway to communicate throughOf cause it depends on your situation. Is it 9600 or 115.2k

author: Jeroen3
author_rank: Super Contributor
timestamp: August 05, 2015, 06:49:07 am
content: Quote from: Psi on August 05, 2015, 06:20:47 amYou'd only need a mutex assigned to the uart and two "processes*" able the use the uart. Since they're not physically able to be active simultaneously, your software can be designed in such a way that the software takes&releases the mutex when needed. The mutex will be hooked to the physical multiplexer.Free mutex, usart disabled. Mutex being taken by A, multiplexer set to Ch1. etc... Simple right?If the peripherals are not depending on each other, this system won't get stuck.*Although the use of an (rt)os can make these resource sharing designs simpler. It is not necessary, two major state-machines called from the super-loop can count as "process" too.Or you could go naive Arduino like and set the multiplexer and use waits in the usart using code.Depends on the application if that is acceptable.

author: remixed123
author_rank: Regular Contributor
timestamp: August 05, 2015, 07:00:48 am
content: Thanks everyone for your opinions and advise!I am using an RTOS, the MCU is an ARM Cortex M3.I was intending to use a Mutex or Semaphore. But may just keep everything in the same thread, as data generated from one IC needs to be communicated to the other IC, in a sequential manner.

author: nctnico
author_rank: Super Contributor
timestamp: August 05, 2015, 10:26:10 am
content: Just make sure to put pull-ups on the RX pins when using tri-state buffers.

author: Tomorokoshi
author_rank: Super Contributor
timestamp: August 05, 2015, 05:02:38 pm
content: Over-the-top solution: SPI to UART interface.http://www.digikey.com/product-search/en?FV=fff40027%2Cfff801b5%2C1c0002&k=spi+uart&mnonly=0&newproducts=0&ColumnSort=0&page=1&stock=1&quantity=0&ptm=0&fid=0&pageSize=25I haven't used things like this but I keep them in mind just in case.

author: Mr.B
author_rank: Unknown
timestamp: August 05, 2015, 07:12:32 pm
content: Quote from: nctnico on August 05, 2015, 10:26:10 amYes, I should have put that in my post...