TDM Support, For Many-Channel Audio I/O

A project log for Teensy Audio Library

CD quality sound processing, integrated with Arduino sketches

paul-stoffregenPaul Stoffregen 04/17/2017 at 20:397 Comments

Some projects need a lot of audio I/O. Maybe you’re doing positional audio sound effects (using the 8-tap delay effect) where ordinary stereo or even 5 channel “surround” isn’t enough? Maybe you’re making the ultimate Eurorack synthesizer module? Or you just want a lot of signals, because you can!

Here’s a board for the Cirrus Logic CS42448 chip, which provides 6 inputs and 8 outputs. All are high quality audio, and all work simultaneously.

TDM Data Interface

Normally digital audio is communicated between chips using I2S protocol (which is different than I2C, despite the similar acronym). Two I2S streams can be used for quad channel, but to really step up to more channels, you need TDM protocol.

TDM, which stands for Time Division Multiplexing, communicates a frame of 256 data bits. For 44.1 kHz, this means the bit clock must be 11.3 MHz. Only 4 signals are used, one to transmit all 256 bits and another to receive all 256, a frame sync signal the marks where each 256 bit frame begins, and of course the 11.3 MHz clock.

Here is the TDM waveform documented by Cirrus Logic for the CS42448 chip.

Actual TDM Signals

When viewed on an oscilloscope, here is how the TDM signal actually appears:

During this test, the code below was running. The output from Teensy is the blue trace. It sends a 16 bit guitar synthesis to CS42448 AOUT1 & AOUT2. Because the CS42448 outputs are 32 bits, but the audio is only 16 bits you can see the lower 16 bits are always zero. Most of the rest of the output is zeros, except this example also brings in AIN1 and sends its top 16 bits to AOUT5 and its lower 16 bits to AOUT6.

Of course, the green trace is the data being received from the CS42448. All 6 inputs were left unconnected. Even through the channel slots of 32 bits, the CS42448 only produces 24 bits of data, and its lower 8-9 bits are mostly random noise. This PCB uses only the simplest single-ended input circuit. The better opamp-based differential circuit documented in the CS42448 could be expected to improve performance.

Software Support

TDM support has recently been added to the Teensy Audio Library. It’s accessed by creating AudioInputTDM and AudioOutputTDM objects.

Each AudioInputTDM creates 16 simultaneous inputs. Like all communication in the Teensy Audio Library, the data is 16 bits wide. 16 of these channels gives access to all 256 incoming TDM bits. For CS42448, only channels 0, 2, 4, 6, 8 & 10 would be really useful.

Likewise, each AudioOutputTDM object can accept 16 simultaneous 16 bit audio streams, to fully control all 256 bits of the TDM output frame. For CS42448, only the 8 even numbered channels are useful.

You might think sustained 11.3 Mbit/sec communication would be difficult on a microcontroller, but it turns out Teensy's digital audio port with FIFO and its DMA engine make this quite easy and efficient. Yes, really!

Development of the audio software support is being discussed on this forum thread. If you make one of these boards, please join the conversation!

Parts Placement Diagram

Bill Of Materials

1   CS42448, Codec Chip            598-1033-ND
 1   CAT811T, Reset Chip            CAT811TTBI-GT3OSCT-ND
 7   Connector, audio               CP1-3525N-ND
 7   Resistor, 150 ohm, 603         311-150HRCT-ND
 8   Resistor, 560 ohm, 603         RMCF0603FT560RCT-ND
 2   Resistor, 2.2K ohm, 603        311-2.20KHRCT-ND
 8   Resistor, 10K ohm, 603         311-10.0KHRCT-ND
 7   Resistor, 100K ohm, 603        311-100KHRCT-ND
14   Capacitor, 2.7nF, NP0, 805     445-7508-1-ND
 4   Capacitor, 10nF, X7R, 603      490-1512-1-ND
 7   Capacitor, 0.1uF, X7R, 603     490-1524-1-ND
14   Capacitor, 4.7uF, X5R, 805     1276-6463-1-ND
 7   Capacitor, 10uF, X5R, 805      399-4925-1-ND
 1   Capacitor, 22uF, X5R, 805      490-1719-1-ND
 1   Capacitor, 100uF, X6T, 1206    490-10525-1-ND
 1   Inductor, Ferrite Bead, 805    490-1054-1-ND
 1   Circuit Board        
 1   Teensy 3.2, 3.5 or 3.6
 2   Socket, 14x1         
 2   Header, 14x1         
 1   Heatsink                       (optional: CS42448 runs hot)


anto wrote 08/01/2019 at 16:31 point

Can we have 8 mono outputs played from PC going to Teenzy 3.6 MCU via ethernet or USB interface in serially and played out via the 8 output ports

  Are you sure? yes | no

Zoé wrote 11/27/2018 at 11:38 point

So pretty!

  Are you sure? yes | no

Andy wrote 11/06/2017 at 04:23 point

Is it possible to do the followings:

(1) Connect THE BOARDS( Teensy + many-channel board) to computer via USB.

(2)From computer using software sendng 8 mono audio streams via USB to THE BOARDS.

(3) Play out the 8 mono audio from 8 audio out ports of THE BOARDS simultaneously.

Thank you.

  Are you sure? yes | no

Paul Stoffregen wrote 11/27/2018 at 08:58 point

Nope, sorry, the USB audio support on Teensy 3.x is limited to stereo.  Bidirectional (simultaneous) stereo is possible.  But 8 channel in both directions is far beyond the bandwidth of 12 Mbit/sec USB.

In the future when we have a Teensy with 480 Mbit/sec USB device, I hope to add this capability.  Late-2019 to early-2020 is the expected time frame.

  Are you sure? yes | no

oshpark wrote 04/18/2017 at 01:47 point

Very impressive!

  Are you sure? yes | no

Paul Stoffregen wrote 04/18/2017 at 01:48 point

I'm sure you saw I also posted this as a shared PCB. ;)

  Are you sure? yes | no

oshpark wrote 04/19/2017 at 16:25 point

Thank you!  Excellent documentation as always! :)

  Are you sure? yes | no