1
\$\begingroup\$

I am designing an audio device that requires two CODECs to be connected to the MCU - two stereo outputs, two stereo inputs. When working with a single codec, no problems with synchronization occur since left/right and input/output DMA streams are always in sync.

But how can I connect two CODECs and use data from all of them at the same time? They are not separate in my application: say, for example, I need to mix two stereo inputs and output the sum to both stereo audio outputs. How do I make sure that DMAs and CODECs are in sync, so that when a half-full DMA transfer occurs on one of them, the other CODEC's buffer is also half-full?

I don't see how making the uC I2S slave will help - there's no guarantee that CODECs themselves are in sync, even if they receive the same MCLK from STM32. Is there some interconnection possibility I'm missing?

I do understand that F7 series have SAI which can be synced exactly for this reason, but, unfortunately, I'm stuck with STM32F4 in this project. Essentially, I need to sync two SPIs... starting them at the same time (one clock apart) may be a solution, but it sounds pretty unstable.

Will turning ONE of the I2S to slave and physically conencting the master I2S clock signals to it help?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ It's been a while since I last worked with such codecs, but as I recall, synchronizing multiple units was a straightforward process, since it is a requirement in many applications. Doesn't the datasheet provide any guidance about that? \$\endgroup\$
    – Dave Tweed
    Commented May 29 at 4:13
  • \$\begingroup\$ @DaveTweed I am using ES8388 codec with I2C configuration protocol. There is no dedicated "sync" pin and synchronization with I2C doesn't seem to be possible - it's a rather slow protocol. Maybe them using the same MCLK will sync them in a way? \$\endgroup\$
    – sx107
    Commented May 29 at 8:56

2 Answers 2

1
\$\begingroup\$

If you had mentioned which codec you were using in your question, this would have been much quicker. Better still, a link to the datasheet would have saved me a bunch of time looking for it.

It's pretty much as I remember. SCLK and LRCK are shown as bidirectional. You put one device in "master" mode (SCLK and LRCK are outputs) and the other device(s) in "slave" mode (SCLK and LRCK are inputs) -- see register 8 on page 16. Connect all the MCLK, SCLK and LRCK signals together. You supply MCLK and the master device supplies SCLK and LRCK to all of the other devices.

\$\endgroup\$
1
  • \$\begingroup\$ To other I2S uC port as well, right? \$\endgroup\$
    – sx107
    Commented May 29 at 21:02
0
\$\begingroup\$

You said:

"I do understand that F7 series have SAI which can be synced exactly for this reason, but, unfortunately, I'm stuck with STM32F4 in this project."

There are STM32F4 with SAIs as shown in this page.

\$\endgroup\$
1
  • \$\begingroup\$ *stuck with f405 \$\endgroup\$
    – sx107
    Commented May 29 at 21:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.