AnsweredAssumed Answered

(solved) CPOL and CPHA inverse when using as slave only?

Question asked by CaCO3.CaCO3 on Sep 29, 2015
Latest reply on Oct 5, 2015 by CaCO3.CaCO3
I am using the STM32F4 as an SPI slave.

The signal is comming with LSB first, CPOL=0, CPHA=0.
See image below, which shows the reception of 0x44:
SPI%200x44.png

Neverthe less, I seem to have to set CPOL=1, CPHA=1 to receive it correctly!
With any other configuration, it gets parsed wrong.
What is wrong?

Below my configuration (as generated by STM32CubeMX:
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_SLAVE;
hspi1.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi1.Init.NSS = SPI_NSS_SOFT;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLED;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED;
hspi1.Init.CRCPolynomial = 10;
HAL_SPI_Init(&hspi1);

Outcomes