What is I2S, and how is it different from I2C?
Short answer: I2S (Inter-IC Sound) is a synchronous serial bus for digital audio between processors, codecs, DACs, ADCs and digital microphones. Despite the similar name, it has nothing to do with I2C: it has a bit clock (BCLK/SCK), a word-select or frame clock (LRCLK/WS, which selects left or right channel and runs at the sample rate), and one or more data lines (SD), plus often a master clock (MCLK) for the codec. It streams audio continuously at a fixed sample rate.
Clock relationships
LRCLK (WS) = sample rate, e.g. 48 kHz
BCLK = sample rate × channels × bits per slot, e.g. 48 kHz × 2 × 32 = 3.072 MHz
MCLK often = 256 × sample rate = 12.288 MHz
Formats: standard I2S (data delayed by one BCLK after the LRCLK edge, MSB first), left-justified, right-justified, and TDM (more than two channels in one frame: multi-mic arrays, multi-channel codecs). PDM is a different 1-bit format used by many MEMS microphones.
Embedded implementation
- Use DMA with double (ping-pong) buffers: the I2S peripheral streams samples continuously, and the CPU processes one buffer while DMA fills or empties the other.
- Underrun/overrun causes audible clicks: size buffers for worst-case processing latency.
- Clock accuracy matters: 44.1 kHz and 48 kHz families need different PLL settings; small mismatches between devices cause drift over time (asynchronous sample-rate conversion or clock recovery for USB audio).
Linux: ALSA SoC (ASoC) with CPU DAI, codec and machine drivers described in the device tree.