AnsweredAssumed Answered

Switching between SPI mode 0 and 1?

Question asked by TSK on Jul 3, 2015
I have a number of devices connected, some sample the data on the rising clock edge, others on the falling edge. Inside the handler structure I want to alternate between these two operation modes.

A method that works is calling the following before each transmit:
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
HAL_SPI_Init(&hspi3);
 
or
 
hspi3.Init.CLKPhase = SPI_PHASE_2EDGE;
HAL_SPI_Init(&hspi3);

This works, but its ugly. Any "neater" ideas? Thanks!

Outcomes