What are the disadvantages of bit banging SPI/I2C in embedded applications

前端 未结 5 759
天涯浪人
天涯浪人 2021-01-05 23:30

I have come to understand that bit banging is horrible practice when it comes to SPI/I2C over GPIO. Why so?

5条回答
  •  太阳男子
    2021-01-06 00:09

    It wouldn't be called horrible as such. But yes, when we implement a protocol using bit-banging, it is very much probable that the controller would miss out doing the other more important task because the protocol may consume more CPU time than what a dedicated hardware would consume. SO, is should be avoided in real-time environment or say, time-critical environment.
    Along with these, there is one more concern with bit-banging, usually while reading from and/or writing to pin, the signal produced normally has more jitter or glitches, especially if the controller is also executing other tasks while communicating.. If at all it is unavoidable to use bit-banging, then at least try and use them with interrupts instead of polling.

提交回复
热议问题