TDM16 looped back audio is distorted

Discussions about USB Audio on XMOS devices
Posts: 1
Joined: Thu Jun 22, 2023 5:44 pm

TDM16 looped back audio is distorted

Post by klebb »

I am using an xCORE-200 Multichannel Audio Platform to prove an audio USB design before committing to PCB. My design is a minor variant of the ‘app_usb_aud_xk_216_mc’ reference design which is included in the ‘sw_usb_audio’ repository. My adaptation is simply to change the (no TDM) I2S inputs/outputs to TDM16. Initially, I tried TDM8 by adding the following build configuration to the Makefile:

Code: Select all

# TDM8 Audio Class 2, Input (16), Output (16), (Yes) MIDI, No SPDIF i/o, No ADAT i/o, No DSD, TDM mode
# Note: sample rate restricted to 96K to fit in USB bandwidth
INCLUDE_ONLY_IN_2i16o16mxxxx_tdm8  = 
which includes the significant flag ‘-DI2S_MODE_TDM=1′. This build worked fine, but then I changed from TDM8 to TDM16 by adding the following line to customdefines.h:

Code: Select all

#define I2S_CHANS_PER_FRAME 16
and changing lines:

Code: Select all

/* Master clock defines (in Hz) */
#define MCLK_441 (512*44100) /* 44.1, 88.2 etc */
#define MCLK_48 (512*48000) /* 48, 96 etc */

Code: Select all

/* Master clock defines (in Hz) */
#define MCLK_441 (256*44100) /* 44.1, 88.2 etc */
#define MCLK_48 (256*48000) /* 48, 96 etc */
(without the latter change, the sclk is delivered at 11.2896MHz , rather than the 22.5792MHz required for TDM16 at 44.1kHz word clock rate.)

This certainly resulted in TDM16 data being produced in the correct format, and with the correct LRCLK and BCLK frequencies (verified using an oscilloscope, and also real-time debugging tools attached to an FPGA that interconnects to the xCORE-200 dev kit via the TDN interface). However, the audio is heavily corrupted – please see attached screenshot. The screenshot shows looped-back audio captured on a PC which is connected to the devkit. The loopback was created simply by wiring together the xDAC_SD1 and iADC_SD1 header pins on the xCORE-200 board. Reverting back to the TDM8 build, the audio was perfect, verifying that there was nothing wrong with the loopback mechanism.

Is there anything else (eg PLL chip set-up) which I should be changing in order to migrate from TDM8 to TDM16?

User avatar
XCore Expert
Posts: 947
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Although TDM16 is beyond the tested scope of the design (XMOS has no development hardware that supports TDM16) it should be expected to operate. A small change was required to properly respect I2S_CHANS_PER_FRAME when calculating bit-clock frequency: ... 74f5260bcf

This made it into the v7.3.1 release of the USB Audio software.

Note, the thread author is using a version 6 release, with more modern release the functionally can be achieved using the following (I2S_MODE_TDM no longer exists):

Code: Select all


After this change there is still a bit-shift issue when using the 216 part (316 appears fine), I believe this relates to:

The user (contacted privately) has updated to the latest sw release and is dealing with the bit-shift in an external device (or will use