Thursday, 9 August 2012

How to choose the proper bus between SPI, I2C, UART?

Uart 
Advantages : single wire, easy interface to PCs,MCU UARTSs etc. range of standard physical interfaces (TTL, RS232, RS422, RS485) covers a big range of distance/speed capabilites with off-the-shelf hardware. 
Disadvantages : Needs reasonable clock accuracy both ends. Max data rate in practice about 1mbit/sec (typically limited by UART capabilities). 

SPI 
Advantages: Potentially very fast (10-20mbits/sec), very simple interface, very easy to implement in hard logic,FPGA or software. 
Self-clocking so can wake an MCU on reception and have the data byte available once woken. 
Flexible data word sizes

Disadvantages : 
Multiple devices need multiple select lines.

I2C
Advantages : 
Only 2 wires to support multiple devices. Multimaster capability
Timing constraints of protocol reduce likelihood of false data (e.g. eeprom corruption) in noisy or powerup/down situations.  

Disadvantages : 
More complex protocol than SPI, harder to level-shift or optoisolate due to bidirectional lines. 
Speed up to 400kbit/sec (1mbit for a few devices), but in practice can be limited to lower rates by capacitance if tracks are long.

No comments:

Post a Comment