Clock phase and clock polarityFour possible timing relationships อาจถูกเลือกโดย software, โดยใช้ the CPOL และ CPHA bits ใน the SPI_CR1 register. The CPOL (clock polarity) bit ควบคุม the steady state value ของ the clock เมื่อไม่มี data ถูกส่งถ่าย. บิตนี้มีผลต่อทั้ง master และ slave modes. ถ้า CPOL ถูก reset, the SCK pin มี a low-level idle state. ถ้า CPOL ถูก set, the SCK pin มี a high-level idle state.
ถ้า the CPHA (clock phase) bit ถูก set, the second edge บน the SCK pin (falling edge ถ้า the CPOL bit ถูก reset, rising edge ถ้า the CPOL bit ถูก set) คือ the MSBit capture strobe. Data ถูก latched บนการเกิดขึ้นของ the second clock transition. ถ้า the CPHA bit ถูก reset, the first edge บน the SCK pin (falling edge ถ้า CPOL bit ถูก set, rising edge ถ้า CPOL bit ถูก reset) คือ the MSBit capture strobe. Data ถูก latched บนการเกิดขึ้นของ the first clock transition.
The combination ของ the CPOL (clock polarity) และ CPHA (clock phase) bits เลือก the data capture clock edge.
Figure 240, แสดง an SPI transfer ด้วย the four combinations ของ the CPHA และ CPOL bits. The diagram อาจถูกตีความได้ว่าเป็น a master หรือ slave timing diagram เมื่อ the SCK pin, the MISO pin, the MOSI pin ถูกต่อโดยตรงระหว่าง the master และ the slave device
Note: ก่อนการเปลี่ยน the CPOL/CPHA bits the SPI ต้องถูกปิดการใช้งานโดยการรีเซ็ต the SPE bit. Master และ slave
ต้องถูกโปรแกรมด้วย the same timing mode.
The idle state ของ SCK ต้องตรงกันกับ the polarity ที่เลือกใน the SPI_CR1 register (โดย pulling up SCK ถ้า
CPOL=1 หรือ pulling down SCK ถ้า CPOL=0).
The Data Frame Format (8- or 16-bit) ถูกเลือกผ่านทาง the DFF bit ใน SPI_CR1 register, และกำหนด the data
length ในระหว่าง transmission/reception.
Data frame formatData สามารถถูก shifted out อย่างใดอย่างหนึ่ง MSB-first หรือ LSB-first ขึ้นอยู่กับค่าของ the LSBFIRST bit ใน the SPI_CR1 Register.
แต่ละ data frame เป็น 8 หรือ 16 bits long ขึ้นอยู่กับขนาดของ the data ที่โปรแกรมโดยใช้ the DFF bit ใน the SPI_CR1 register. The selected data frame format ใช้ได้สำหรับ transmission และ/หรือ reception.