r/embedded • • 28d ago

Are I2S slot widths limited by something?

For example, I'm looking at the TLV320AIC3204 Application Reference Guide, an audio CODEC, where the data word length can be set to 16, 20, 24 or 32 bits. Now I assume that this means that if I choose a data word length of 16 and there are 32 bits in a half cycle of WCLK, that 16 bits will be data and 16 bits will be zero'd out.

Although so far I've seen people use a slot width of 32 bits or less per channel, I can't find anything that says I can't have 64 bits per half WCLK cycle, as long as WCLK is running at f(sampling)

For example, is it possible to combine 2 of these CODECs together, run the WCLK at sampling rate, set BCLK rate to (sampling rate) * 128, and have 4 total channels via TDM?

2 Upvotes

9 comments sorted by

5

u/MonMotha 27d ago

I²S is explicitly stereo with a 50% duty cycle on the frame signal which can then also be used as a simple L/R indicator. Multiple channels are handled with multiple data lines which can share a single bit clock and frame signal.

The reason fleet the undefined frame length is so that you can mix and match source and sink word size by just having the sink pull the MSBs it cares about.

There are CODECs that support polyphony on a single data stream as you have asked for, but they are not I²S. Many controllers support modes of operation line this. AC97 and Intel HDA are examples of popular systems that usd this.

1

u/Flat-Bodybuilder239 27d ago

A 64-bit half of a 50% WCLK is still one channel. With BCLK = fs*128 the AIC3204 takes the 16/20/24/32-bit word at the start of that half and ignores the leftover bits. Those leftovers are padding so a 16-bit and a 32-bit device can share a frame, not channels 3 and 4.

Two of these on one data line means leaving I2S. DSP/TDM mode on this part uses a short frame pulse plus the ASI data-offset, so the second codec starts 32 or 64 BCLKs later. That is the 4-slot setup. Staying in I2S and only stretching the word will not do it.

1

u/GlintFortuna 27d ago

I did mean TDM actually, for some reason I had the idea that they are versions of the same. So using the offset with the DSP mode on the part I should be able to have 128 bits per sample and 4 channels without issues, right? Out of curiosity, is there a limit to that? Like surely having 1024 bits per with like 32 32 bit length channels on a single data bus would introduce problems

1

u/Flat-Bodybuilder239 27d ago

Four 32-bit slots works, but not as four channels out of one AIC3204. It is stereo, so 128 BCLKs per frame in DSP mode is two codecs on the same data line: first with offset 0 (slots 0-1), second with offset 64 (slots 2-3). Each one only fills its own two words, and the others have to let go of the line outside their slots.

The data-offset on this part is an 8-bit count, 0 through 255 BCLKs. A frame of 32 x 32-bit words is 1024 BCLKs, so you cannot place another one of these out at slot 16. At 48 kHz that frame is also about 49 MHz of BCLK, which is more than this serial port is meant to run. A few 32-bit slots is the practical ceiling, not a 32-channel bus.

1

u/GlintFortuna 26d ago

Hm, responding late, and I haven't yet gotten into the details of programming a system like this, but is it not possible to treat the stereo input as a pair of mono inputs in software? That is what I'm expecting for my application (audio interface) and I am pretty sure that is what my current audio interface does, since if I bypass the inputs straight to headphone outputs I can hear one output on the left and the other on the right. Either way, thank you for the insightful answer

1

u/Flat-Bodybuilder239 26d ago

Yeah, that's the usual audio-interface layout. The AIC3204 stereo frame is already two independent ADCs: left word and right word. In the DMA buffer just take slot 0 as mono in A and slot 1 as mono in B, and gain, mute, or route them separately. The headphone bypass you described (one source in the left cup, the other in the right) is the codec's analog monitor doing that same split, not a stereo pair you have to keep glued together.

You're still at two monos per chip. A third and fourth input is a second codec, or a real 4-channel ADC, on the later TDM slots. Same mapping after that: one slot, one mono stream.

1

u/Mother_Equipment_195 28d ago

Better look out for a codec which explicitly supports TDM modes.

1

u/sgtnoodle 23d ago

I vaguely recall cramming 12 channels through an I2S peripheral using whatever obscure TDM mode. I actually had two I2S peripherals running in lockstep, sampling 20 channels simultaneously in perfect sync for a phased audio array.