cancel
Showing results for 
Search instead for 
Did you mean: 

Frame synchronization randomly swapping.

KJans.1
Associate II

I have a STM32L433 driving a FDA802 using SAI in I2S standard mode, and it randomly swaps the left and right channels. I have compiled with a small table of interleaved data (two sine waves of different amplitudes) to try an fault find. the code I am testing now simply sets up the SAI, initializes the amplifier over I2C and then the DMA after which it runs the DMA in circular mode, disabling all interrupts and running a while loop to ensure nothing else is interfering . After a while watching on the scope I can see my Left and right channels have swapped. This happens ever time I run it and will never correct itself.

  hsai_BlockA1.Instance = SAI1_Block_A;
  hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_TX;
  hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS;
  hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
  hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE;
  hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;
  hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_48K;
  hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE;
  hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE;
  hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING;
  hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED;
  if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_16BITEXTENDED, 2) != HAL_OK)
  {
    Error_Handler();
  }

I am running this on another product with a STMH723 and a FDA802 and am having no issues. I am leaning towards a board layout issue but I am wondering if there is anything I have overlooked, or maybe someone has experienced something similar?

thanks so much.

2 REPLIES 2
KJans.1
Associate II

Further to the above, I can see the WS swapping on the scope side even though the buffers are still populated in the correct order of interleaved data, so I assume the FDA802 amplifier is not the issue and is simply doing what it is told. Also this seems to only happen when the output is under load.

How do you know it's the WS swapping not the data in your buffers? And, if it's really the WS, then check the potential corruption of SAI_xFRCR register, especially FSPOL bit.