MCU with several serial ports - Page 1
Forum section: electronics / general

author: Costa
author_rank: Newbie
timestamp: May 31, 2021, 10:42:51 pm
content: Dear all,I need an advice about MCU. Because all this Covid nightmare, we are planning to start a new business. Basically, we are designing toys for little kids and one project requieres electronics. We are looking for a low cost (less than $1) MCU. I saw posts about Padauk but it seems their MCU does not support I2C nor UART. Do you know another low cost MCU with a least 4 serial ports? Memory is not an issue because task (code) is very simple.Thanks in advance for your answer.Costa

author: langwadt
author_rank: Super Contributor
timestamp: May 31, 2021, 10:44:55 pm
content: Quote from: Costa on May 31, 2021, 10:42:51 pmwhat baudrate?

author: Whales
author_rank: Super Contributor
timestamp: May 31, 2021, 11:07:52 pm
content: STC8(or the older but still prevalent STC15) micros might be an option. Some models have 4 UARTs according to thedatasheets, but I've only ever used 2.Availability:buy through LCSC. Not sure of stock availability at the moment (EDIT: bugger,looks like there is only stock in the more expensive units), have not purchased any since last year or so.Toolchain:I ignore their official tools and use an open source toolchain instead. SDCC as the compiler and stcgal as the programmer. Really easy, about the same difficulty level as avrgcc + avrdude.The fact it's an 8051 core makes it super easy to deal with in SDCC, you just have to define the any STC-custom registers at the top of your source code before using them (their addresses are all detailed in the datasheet along with example code). I wrote a little tool to convert the "official" header files from STC's tools into SDCC-compatible header files, but that was probably overkill.8051 is also a PITA sometimes, make sure to read up on the memory model & the different pointer types in the SDCC manual! By default all pointers are super-magic-every-memory-type-pointers that are very slow and take up lots of space. May or may not be an issue for you.Programmer: done over UART0. I use a cheap USB UART and 3/4 wires (GND, TX, RX and an optional VCC)

author: Whales
author_rank: Super Contributor
timestamp: May 31, 2021, 11:12:22 pm
content: It occurs to me that, during this stock-level crisis, we should look for really crappy chips that no-one ever buys and use those instead xDAnyone for Intel Gallileos?

author: Costa
author_rank: Newbie
timestamp: May 31, 2021, 11:13:34 pm
content: I forgot to mention one must be I2C (100 kHz is ok) and the other 3 could be UART (9600 bps or lower) but 4 x I2C works too. Speed is not an issue.Thanks

author: nctnico
author_rank: Super Contributor
timestamp: May 31, 2021, 11:37:02 pm
content: I2C is super easy to bit-bang (but don't forget to add support for clock stretching). Switch the port pins between input & output (which the output set to 0 / low) to mimic an open drain output.

author: Costa
author_rank: Newbie
timestamp: May 31, 2021, 11:48:48 pm
content: Thanks for your answers. Is it possible with Padauk's MCU (for instance PMS150C) bit-banging to create 4 serial ports?Thanks

author: langwadt
author_rank: Super Contributor
timestamp: May 31, 2021, 11:54:10 pm
content: Quote from: Costa on May 31, 2021, 11:48:48 pmdo you need both transmit and receive ?

author: Costa
author_rank: Newbie
timestamp: June 01, 2021, 01:01:59 am
content: Through the I2C yes. Master and slaves with interchange just IDs. Through the other ports, each port will only transmit or receive.Thanks

author: PCB.Wiz
author_rank: Super Contributor
timestamp: June 01, 2021, 02:49:20 am
content: Quote from: Costa on May 31, 2021, 10:42:51 pmWhat exactly do the ports talks to ?Quote from: Costa on May 31, 2021, 11:13:34 pmDoes it need to be i2c master, or slave.i2c master is relatively simple to generate up to 8 ports on, you just place SDA into a byte-mask, and use byte level port access.Quote from: Costa on June 01, 2021, 01:01:59 amIf remote slaves only respond when talked to, you can also do a similar thing with bit banged UARTS - Select a channel mask for TX, and then listen to that RX paired pin.Ports are polled on a round robin scheme.If any port can talk at any time, that quickly gets more difficult.You need to have (eg) 4 interrupts ready, and if you have a MCU with 4 timers, then a start bit interrupt can launch the timer=phased RX.There are many MCUs with serial peripherals, under your $1eg the Nuvoton MS51FB9 has serials ports as per attached, which also shows the multiple pin maps possible for each.SiLabs EFM8 series have peripherals that can allocate via a port-mux, again useful for one-at-a-time MCU-is-master uses.These days, you may want to check availability of MCUs