Electronic – Designing system for multiple SPI and I2C slaves

microcontrollerstm32f4

I'm designing a system that has 2 SPI slaves and 3 I2C slaves. The master for all of the communication is STM32F429, which has 6 SPI and 3 I2C peripherals. I think I have two options: 1) use a different peripheral for each slave device (5 peripherals in total), we'll call this SEPARATE or 2) use one SPI for both SPI slaves and one I2C for all 3 I2C slaves (2 peripherals in total), we'll call this COMBINED.

My question is:

What are the pros/cons of using SEPARATE vs COMBINED?

  • Pro COMBINED: Routing for COMBINED is simpler because shared lines
    don't have to all go all the way back to the micro.
  • Pro COMBINED: Extra pull-up resistors will be required for SEPARATE for each I2C bus.
  • Pro SEPARATE: If I use the DMA, I can initiate every transfer simultaneously without taking up cpu time, and perform cpu operations
    once all the data arrives (is this true?)
  • Pro SEPARATE: Any I2C devices that are slower won't hold up the other I2C slaves since they're on separate buses.
  • What other pros/cons are there?

Best Answer

You have covered the 'electrical' and 'finished state' issues pretty well.

However, think of the process of building, debugging and testing the system.

The potential advantages of SEPARATE seem to be quite compelling:

  • Any electrical problems or bugs should only effect one device
  • Software for each slave device should be independent, so testing parts of the incomplete system should be easier because of this
  • The devices might need slightly different I2C (and maybe SPI) setups. For example, the data and clock may be in different phases, or worse, may use the same I2C address.
  • Finally, it would be relatively easy to combine slaves on a common peripheral, once everything is working, but getting the whole system working will be harder on shared peripheral interfaces.
Related Topic