Embedded Systems & Firmware
When an SPI part is connected but correct data cannot be read, which setting is most worth checking?
- AWhether the I2C address matches the part
- BWhether the UART baud rate matches the part
- CWhether the clock polarity and phase (CPOL and CPHA, the SPI mode) match the part's specification
Show answer and explanation
Answer: C. Whether the clock polarity and phase (CPOL and CPHA, the SPI mode) match the part's specification
SPI has four modes formed by combining the idle level of the clock (CPOL) and which clock edge samples the data (CPHA). If master and part use different modes, sampling is off by half a period, shifting bits or giving undefined values. The mode must be checked in the part's datasheet and the microcontroller's SPI configured to match.
- A. SPI has no addresses.
- B. SPI does not synchronize via a baud rate.
- C. Correct. Which of the four modes is used depends on the part.