Skip to main content
monomonster
Associate II
July 3, 2015
Question

Switching between SPI mode 0 and 1?

  • July 3, 2015
  • 0 replies
  • 901 views
Posted on July 03, 2015 at 12:48

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!
    This topic has been closed for replies.