0

I want to access both of the multiplexed I2C and UART pins in the same program. I am programming in Arduino IDE.Can anyone please tell me how to access same pins for different functionalities?

  • I want to use Serial debug and MPU6050 in my application. All other pins are occupied with one or the other sensors and other devices. Only PB6 and PB7 is left., which is UART and I2C and I need both. – Jackie Jan 2 at 11:44
  • And how do you propose to remove the I2C device when using UART, and to remove the UART connection when using I2C? – Majenko Jan 2 at 15:37
  • If your chosen MCU doesn't have the resources that you need then you have chosen the wrong MCU. – Majenko Jan 2 at 15:41
  • do you have a network connection on the MCU? WiFi or Ethernet? use Telnet for debug output – Juraj Jan 2 at 15:53
  • No I dont have any network connection in the MCU – Jackie Jan 3 at 4:59
1

In order to use two different peripherals on the same pins, you have to initialize I2C and de-intialize UART when using I2C and doing the opposite when using UART.

It’s not possible to initialize two different peripherlas on the same pins, concurrently.

1

You can't. (Well, you can, but you mustn't).

I2C and UART are electrically incompatible bus systems. UART is a Push-Pull system, whereas I2C is an Open-Drain system. The Push-Pull connections will interfere with the Open-Drain outputs and I2C will not function.

If you want to have both you will need to include extra hardware (and the necessary control pins) to physically isolate the different devices from their respective bus when not in use.

  • Can I use a multiplexer to isolate the devices? – Jackie Jan 3 at 5:05
  • how do you want to control the multiplexer? – Juraj Jan 3 at 16:57
  • Only if it's a specialised multiplexer that knows about both UART and I2C. And I doubt such a thing exists. – Majenko Jan 3 at 17:04

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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