Assuming you’ve got peripheral libraries for both, about the same. If you have to write peripheral libraries yourself, I2C is much more complex. If you have to bit bang the interface then that’s going to add additional headaches. You should review the libraries available for the peripheral and how the resources are used for your particular micro-controller. The Interface should be thought about carefully, what you need it to do, what its capable of doing and how you intend to advance the interface. If you have ever used an STM32F1, you may have noticed that USB and CAN share the same resources, trying to code around this if both are needed is a nightmare. The complexity of your code is also going to depend on the topology of the network and how nodes communicate. It depends on what is being connected and to some extent on cost as well (I2C is usually more expensive).

For connecting switches (user configuration switches) and lights (indicator LEDs, LCD displays) SPI to reduce pin count on small microcontrollers which are highly pin limited.

< Prodigy Community Forum – Click here