Electronic – arduino – I2C & SPI – share clock lines

arduinoi2cspi

I know mixing SPI and I2C is a bad idea, but, when using a microcontroller short on pins, is it safe to share clocks between both buses, provided both are running at bus-tolerable frequencies?

In my application, I plan on using one bus at a time, but I suppose this question applies even if that was not the case.

Best Answer

You could theoretically do this but you'd have to use two different buffers. The system I'm envisioning would have a bidirectional buffer with tri states might work (or maybe two) and you could switch the SPI bus on and the I2C bus off.

The pull ups for I2C could be on the other side of the buffer

However if one is using a small micro, they are probably doing so to save on space and you might as well use a bigger micro than a micro and a buffer (or two).