AnsweredAssumed Answered

Synchronizing SPDIFRX and SAI clocks

Question asked by Giulio Girardi on Aug 29, 2017
Latest reply on Jan 16, 2018 by waclawek.jan

Hi everyone,


For the last week I've been trying to capture a SPDIF stream (at 48000 Hz) through the SPDIFRX peripheral with the STM32F745 MCU and redirect it through a SAI output (connected to an external DAC).


The main issue I've been facing so far is the difference between the SPDIF clock, which is generated by the external SPDIF device I've connected to the MCU, and the SAI clock, which is being generated by a PLL in the MCU. This means that the two interfaces' DMAs trigger with a slightly different frequence, and this leads to a periodic stream data corruption.


What I'd prefer not to do:

  • Resampling;
  • Polyphase filtering;
  • In general, time consuming operations.


What I've tried so far (without success):

  • Configuring two different PLLs, one to generate a frequency slightly higher than 48000 Hz, the other slightly lower. I've than implemented an algorithm that swaps the PLL that the SAI peripheral is currently using, with the other, whenever the SAI DMA is about to go out of sync. This approach sort of works, but the final stream jitters way too much, creating a tremolo effect;
  • Changing the other PLL frequency when the SAI is clocked on the other to adapt it to the SPDIF clock. This approach doesn't work because changing the PLL frequency requires that the PLL itself is disabled, but the SPDIF peripheral needs an internal clock too, which is one of the two PLL I can use for the SAI, so switching it off kills the SPDIF reception;
  • Swapping the clocks every DMA cycle, to avoid the jitter. This doesn't work either, because it modulates the stream, creating too many harmonics.


My last possibility:

In the MCU reference manual (RM0385) paragraph 34.3.10 (SPDIFRX Symbol Clock Generation) is reported:

The SPDIFRX block provides a symbol clock on signal named spdifrx_ck_symb, which
can be used as the reference kernel clock for another audio device such as SAI or SPI/I2S.
It could be used for SPDIFRX to I2S bridge function.

But this signal isn't reported anywhere else.


What should it be connected to? A timer? The PLL itself? A GPIO pin?

Is there any snippet of code describing how to use it or someone who has tried this functionality?


Thanks in advance