gif gif

The interesting corner

gif gif

Combining serial communication pins

For a project I was working on, we needed to combine several serial communication pins. We first wanted to do this using a multiplexer IC like the SN74CBT3257C. But, we ultimately decided to use the multiplexing abilities of the microcontroller we were going to use, as it could enable or disable the protocols depending on wether or not you are using them. To prevent any current from flowing into the communication ports, we tried to use a 10kΩ resistor. To test if this would work, I built a simple setup using an STM32 NUCLEO F446RE (and here) board, together with an ESP32 board. I tested the I²C and USART protocols. Below is a picture of the setup.

setup picture

First, I tested the I²C. The ESP32 board was set up as a master that would send information, and the STM32 board acted as a slave with address 0x09 that received the data. The result of this transmission can be seen in below. The top signal is the CLK (clock) and the bottom signal is the SDA (data).

i2c comm

You can see that the setup message was sent, but was responded with a NAK. This means that the master could not find a device with address 0x09 on the I²C bus. I figured it was because the resistor value was too high and it decreased the voltage of the communication lines too much, so I swapped it out for a 4.7kΩ resistor. After testing the communication again, the result was as follows:

i2c comm 2

This figure shows that the master successfully found the slave device with address 0x09 and sent the test message hello. After verifying that I²C communication was possible using this design, USART was checked. The result of this can be seen in the figure below. In this figure, the top signal is the sent data, and the bottom signal is the response. It is visible that first the message Hello from UART 2 is sent, after which the response hello is sent back.

usart received

All the code for the testing can be found here. It's a lot of empty projects because I had some trouble with broken dev boards while trying this.