This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Need a suggestion about inter-MCUs communication

Hi there,

Lets say we have two micros and they have to talk to each other without the arbiter. So at this setup there is no slaves.

I am wondering what interface is more stable and reliable I2C or SPI and why?

Thanks.

Stan

  • >So at this setup there is no slaves.
    No slaves? - Then only asynchronous serial interface (USART) match your requirements.

    In case you are fine with slave/master then use SPI which is seemingly simpler
  • Hi Ilmars, Thanks for the advice! Will look into USART features.

    I do not have slave devices at all. And the main purpose is to connect two MCUs with the same hierarchy level.
    But why not I2C? By default they both can be slaves and listen to the bus and if any of those wants to send some data it reconfigures to a master and then back to a slave. The only question here what if both want to transfer data at the same time?

    Thanks.
    Stan
  • The only question here what if both want to transfer data at the same time?

    That problem does not arise on the I2C bus, since it has one dedicated master that initiates all transfers. Slaves cannot start transfers.

    The same would be true for the SPI bus.

    If that doesn't match your requirements, the UART/USART would be the better alternative.

  • Hi f.m., thanks for the reply.

    Of course I2C slaves cannot initiate the transfer. But as I have said both devices are at the same level on hierarchy so accidentally they can re-configure themselves to be a master and attempt to send data. 

    So anyway I agree that UART is the simplest and the most reliable interface for this application.

    Thanks guys for help.

  • Hi Stan,
    If both the uC tries to transmit the data in i2c then arbitration will occurred, during that time the uC which sends more number of dominant bits win the bus and start transmission. Please see more information about arbitration in i2c.
  • >If both the uC tries to transmit the data in i2c then arbitration will occurred
    Right, however using i2c does not makes sense in this case. USART is best choice here due to simplicity compared to i2c and independent clocking (no master) for each tx direction.

**Attention** This is a public forum