jawi / ols

OpenBench LogicSniffer repository
http://www.lxtreme.nl/ols/
319 stars 75 forks source link

Possibly incorrect SPI CPHA value #233

Closed catamphetamine closed 8 years ago

catamphetamine commented 8 years ago

Hello. Today I'm debugging SPI on STM32 with:

    SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
    SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;

But the program shows me that CPHA is 1 (see the screenshot). I'm not an SPI expert but it seems to me that CPHA is actually 0 here, not 1.

I'm assuming CPHA = 0 means "capture value on the rising edge: https://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus

For CPHA=0, data are captured on the clock's rising edge (low→high transition) and data is output on a falling edge (high→low clock transition).
For CPHA=1, data are captured on the clock's falling edge and data is output on a rising edge.

(the screenshot below is for the fourth transmitted byte = 0x3 = 0000 0011)

screen shot 2016-06-12 at 17 26 52

catamphetamine commented 8 years ago

Or maybe not: today my STM32 works correctly with 0 0.