C51 SPI

From ElectroDragon Wiki
Revision as of 21:51, 23 May 2021 by Chao (talk | contribs) (Created page with "SPI通信有4种不同的模式,不同的从设备可能在出厂是就是配置为某种模式,这是不能改变的;但我们的通信双方必须是工作在同一模...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SPI通信有4种不同的模式,不同的从设备可能在出厂是就是配置为某种模式,这是不能改变的;但我们的通信双方必须是工作在同一模式下,所以我们可以对我们的主设备的SPI模式进行配置,通过CPOL(Clock Polarity 时钟极性)和CPHA(Clock Phase 时钟相位)来控制我们主设备的通信模式,具体如下:

      Mode0:CPOL=0,CPHA=0
      Mode1:CPOL=0,CPHA=1
      Mode2:CPOL=1,CPHA=0
      Mode3:CPOL=1,CPHA=1