Search code examples
embeddedmicrocontrollerspiserial-communication

The use of CPOL/CPHA settings in SPI communication


Could any one please give me real life examples where the 4 modes of CPOL/CPHA configuration in SPI communication are useful? I understand how they work but fail to know when to use them. I have read some refer shortly for compatibility purposes due to non-standard implementations, how is this so?

Thanks


Solution

  • Let me try to address the question why there are 4 modes introduced. I can't provide any hard evidence, yet I believe this is a possible explanation:

    First of all - SPI is pretty simple, it's all about sending some stream of bits serially, with separate clock and data lines, the SPI mode controls the clock polarity and phase. Given the simplicity of SPI, all you need to, for example, implement SPI slave device is a serial-in shift register, like 74HC595 (see a sample application).

    Now, while SPI device manufacturers could obviously have agreed upon one mode used universally, I believe that additional modes were introduced to make it simple to interface with simple shift registers. There are many available, with various requirements regarding clock polarity/phase - SPI modes make it easier to connect them without any glue logic.