Skip to main content
Associate II
August 17, 2026
Question

Synchro issue SAI1A and SAI2B STM32F756

  • August 17, 2026
  • 6 replies
  • 18 views

Hello everyone,

I am currently working on a project on STM32F756 with SAI1A as asynchronous master and SAI2B as synchronous slave.

Config :

  • TDM Mode frame length 256, data size 32, slots 8
  • Freq 96k
  • Fifo threshold full
  • Master ext sync out enable
  • Slave sync with SAI1

Then in my code I call HAL_SAI_Transmit_DMA for Slave then for Master but the Slave sends its data 5 us before the master because BCLK and FS clocks are always active.

So the Slave does not wait for the master to have its buffer ready. They should be synchro with this config right ?

 

Is there a way to have perfect sync between both SAIs ?

 

Thanks

6 replies

waclawek.jan
Super User
August 17, 2026

Sync just means that clocks are interconnected from master to slave on-chip. There’s no “data are ready or not” signal - in fact, you are supposed to supply data *before* enabling the modules/starting clocks. So do just that - first set up everything, including DMA, then as the last step enable the master sai (SAI1_ACR1.SAIEN = 1).

Now you use Cube/HAL and I don’t so I don’t know how does this fare with Cube/HAL’s built in automagic; but Cube/HAL is open source, so you can check; and also you can single-step and observe how registers are filled.

JW

AScha.3
Super User
August 17, 2026

Hi,

seems you still dont understand, what the SAI doing, depending on your settings. :)

So they will be sync if you start them (as you do..?) :

  1.  slave start ( no BCLK and FS clocks , because they are from SAI1A , which is still doing nothing)
  1. master start (now BCLK and FS clocks coming out and both 1A + 2B working )
  2. both have to get exactly same settings (frame, bits...etc)
  3. for continuous streams both have to be with circular DMA , otherwise normal DMA with same block sizes.

btw

I have 3 SAI running this way, 6 audio channels, and there never is any out of sync, even after many hours of running.

(+ all is just HAL calls , no problem at all. )

If you feel a post has answered your question, please click on " Best Answer ".
pti_juAuthor
Associate II
August 17, 2026

Hi, thank you for your answer.

Yes I noticed when slave starts first there is no clock or FS, ans when master starts both are on sync, but once the master sent his first data buffer both the clock and FS are running so the next time the slave starts, it's out of sync.

I'm not using continuous stream, I'm sending pulses at specific timings. 

I tried to stop and restart the SAIs between 2 send but it's not resolving the issue.

 

Both SAIs have the same settings and send the same data buffer.

 

AScha.3
Super User
August 17, 2026

Hi,

>I'm not using continuous stream, I'm sending pulses at specific timings. 

That's not reliable possible. 

So tell me, what it should do ? why pulses or pulse packets ? what is target, dac, codec ?

If you feel a post has answered your question, please click on " Best Answer ".
AScha.3
Super User
August 17, 2026

Ok, still no info about the timing signal/pause, frequency range etc.

So just the basic way, how to do it: 

First you set up all SAI channels with circular buffers and callbacks.

Then, buffers with zero data filled, the slaves and then the master is started.

Any sound, that should be generated, is just copied in the callbacks to the desired target 

Then everything has the correct moment and no phase or sync errors, sounds can have any length and silence after the sound is just setting the buffers to zero.

This way all will be running fine, as long as the buffers are filled in the callbacks in time. And the streams running always, never been stopped.

The size of the buffers is up to you, it's a optimum balance between the minimum time you want to have as one half-buffer and the time and overhead you get by choosing to short buffers.

Possible could be any size from 16 samples up to 4K samples.

If you feel a post has answered your question, please click on " Best Answer ".