Skip to main content
Visitor II
January 23, 2025
Solved

Timer and SPI clock synchronization on STM32F407

  • January 23, 2025
  • 2 replies
  • 787 views

Dear All,

I would like to interface an ADC (ADS131M08) with a STM32F407. The ADC datasheet mentions that for better performance, the ADC clock should be synchronized with the SPI clock. Is there any way to achieve such synchronization with the STM? I was thinking about a timer that can give the clock to the ADC and get this timer sync with the SPI, but I don't really see if it's possible and how to implement it.

Thanks for your help

Best regards

    This topic has been closed for replies.
    Best answer by Sarra.S

    Hello again, 

    For synchronization, you can use interrupt or polling to detect the rising edge of the PWM signal.

    You can also use the input capture feature of another timer to detect the edge and trigger SPI communication

    Either way, there are several examples using timers in the STM32F4CubeFW 

    2 replies

    ST Employee
    January 23, 2025

    Hello @Yves_P

    You can use one of the timers to generate the ADC clock signal; configure the timer to generate a PWM signal at the desired ADC clock frequency. Then, set the SPI peripheral to operate at a frequency that is a multiple or sub-multiple of the ADC clock frequency

    Yves_PAuthor
    Visitor II
    January 24, 2025

    Hello @Sarra.S,

    Thanks for this prompt answer. As I understand it, since both clocks derive from the main STM clock, as long as the PWM timer and SPI clock are multiple or sub multiple from each other, they must be somehow synchronized. Am I correct?

    Is there any way to specify or force the first SPI clock rising edge to be in phase with a PWM timer rising edge ?

    Thanks for your help

    Best regards 

     

    Sarra.SAnswer
    ST Employee
    January 24, 2025

    Hello again, 

    For synchronization, you can use interrupt or polling to detect the rising edge of the PWM signal.

    You can also use the input capture feature of another timer to detect the edge and trigger SPI communication

    Either way, there are several examples using timers in the STM32F4CubeFW