CS42448 TDM Input

Not open for further replies.

I recently purchased one of the CS42448 boards from Osh Park, and was able to get output using a sine block connected to the TDM Output block. I would like to connect my audio amplifier's TDM signals directly to the CS42448 board to read the audio data without using the aux ports, and to analyze it. I am in need of any suggestions on how to connect my TDM signals to this board.
We're talking about this board, right?


The 5 TDM signals are connected between the CS42448 and the Teensy by that board, so you shouldn't need to do anything extra on the hardware. Receiving uses pin 13 for all the incoming data, and shares clock pins 9, 11, 23 with transmitting data.

On the software side, just put this TDM input object into your design.


The 6 input signals will appear at ports 0, 2, 4, 6, 8, 10 of that TDM object. Leave the other 10 unused in the design.

In your code, make sure you have a large enough number for AudioMemory(). The TDM object alone will need 16 blocks, so use a number like 40 or more so you're giving the audio library enough memory to do all the work.
Yes, that is correct! Thanks for the quick reply, Paul. I was able to successfully get TDM output using an aux cable as input, and headphones as output. But, when I connect my USBStreamer device's TDM connections to the Teensy's pins, I hear loud static which changes in frequency and volume depending on the song I play, as if it is attempting to play audio. Is it possible I would need to change some of the register settings based on the input device I have?
Do you want me to help figure out what's wrong?

The very first step is to post a complete (and hopefully small) program which I can run on my CS42448 here, to reproduce the problem.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioControlCS42448 CS42448_Chip; //xy=334.99999237060547,42.000009536743164
AudioInputTDM TDMInput; //xy=300.00000381469727,344
AudioOutputTDM TDMOutput; //xy=1027.0834007263184,335.0556411743164

AudioAnalyzePeak Peak_Ch1L; //xy=679.0000076293945,60.0000057220459
AudioAnalyzePeak Peak_Ch1R; //xy=679,93.00000190734863
AudioAnalyzePeak Peak_Ch2L; //xy=679.0000076293945,127.00000190734863
AudioAnalyzePeak Peak_Ch2R; //xy=680.0000076293945,160.00000190734863
AudioAnalyzePeak Peak_Ch3L; //xy=679.0000076293945,194.00000286102295
AudioAnalyzePeak Peak_Ch3R; //xy=677.0000076293945,228.00000286102295
AudioAnalyzePeak Peak_Ch4L; //xy=678.0000076293945,264.00000381469727
AudioAnalyzePeak Peak_Ch4R; //xy=678.0000076293945,297.00000381469727
AudioAnalyzePeak Peak_Ch5L; //xy=679.0000076293945,332.0000047683716
AudioAnalyzePeak Peak_Ch5R; //xy=679.0000076293945,366.0000057220459
AudioAnalyzePeak Peak_Ch6R; //xy=679.0000076293945,434.0000057220459
AudioAnalyzePeak Peak_Ch8R; //xy=679.0000076293945,580.0000095367432
AudioAnalyzePeak Peak_Ch6L; //xy=680.0000076293945,400.0000057220459
AudioAnalyzePeak Peak_Ch7R; //xy=680.0000076293945,507.0000078678131
AudioAnalyzePeak Peak_Ch8L; //xy=680.0000076293945,544.0000085830688
AudioAnalyzePeak Peak_Ch7L; //xy=681.0000076293945,471.00000762939453

AudioConnection patchCord1(TDMInput, 0, Peak_Ch1L, 0);
AudioConnection patchCord2(TDMInput, 0, TDMOutput, 0);
AudioConnection patchCord3(TDMInput, 1, Peak_Ch1R, 0);
AudioConnection patchCord4(TDMInput, 1, TDMOutput, 1);
AudioConnection patchCord5(TDMInput, 2, Peak_Ch2L, 0);
AudioConnection patchCord6(TDMInput, 2, TDMOutput, 2);
AudioConnection patchCord7(TDMInput, 3, Peak_Ch2R, 0);
AudioConnection patchCord8(TDMInput, 3, TDMOutput, 3);
AudioConnection patchCord9(TDMInput, 4, Peak_Ch3L, 0);
AudioConnection patchCord10(TDMInput, 4, TDMOutput, 4);
AudioConnection patchCord11(TDMInput, 5, Peak_Ch3R, 0);
AudioConnection patchCord12(TDMInput, 5, TDMOutput, 5);
AudioConnection patchCord13(TDMInput, 6, Peak_Ch4L, 0);
AudioConnection patchCord14(TDMInput, 6, TDMOutput, 6);
AudioConnection patchCord15(TDMInput, 7, Peak_Ch4R, 0);
AudioConnection patchCord16(TDMInput, 7, TDMOutput, 7);
AudioConnection patchCord17(TDMInput, 8, Peak_Ch5L, 0);
AudioConnection patchCord18(TDMInput, 8, TDMOutput, 8);
AudioConnection patchCord19(TDMInput, 9, Peak_Ch5R, 0);
AudioConnection patchCord20(TDMInput, 9, TDMOutput, 9);
AudioConnection patchCord21(TDMInput, 10, Peak_Ch6L, 0);
AudioConnection patchCord22(TDMInput, 10, TDMOutput, 10);
AudioConnection patchCord23(TDMInput, 11, Peak_Ch6R, 0);
AudioConnection patchCord24(TDMInput, 11, TDMOutput, 11);
AudioConnection patchCord25(TDMInput, 12, Peak_Ch7L, 0);
AudioConnection patchCord26(TDMInput, 12, TDMOutput, 12);
AudioConnection patchCord27(TDMInput, 13, Peak_Ch7R, 0);
AudioConnection patchCord28(TDMInput, 13, TDMOutput, 13);
AudioConnection patchCord29(TDMInput, 14, Peak_Ch8L, 0);
AudioConnection patchCord30(TDMInput, 14, TDMOutput, 14);
AudioConnection patchCord31(TDMInput, 15, Peak_Ch8R, 0);
AudioConnection patchCord32(TDMInput, 15, TDMOutput, 15);

//select peak val variables for all 8 channels
int CH1_LPeak, CH1_RPeak, CH2_LPeak, CH2_RPeak, CH3_LPeak, CH3_RPeak,
CH4_LPeak, CH4_RPeak, CH5_LPeak, CH5_RPeak, CH6_LPeak, CH6_RPeak,
CH7_LPeak, CH7_RPeak, CH8_LPeak, CH8_RPeak;

// GUItool: end automatically generated code

void setup()

void loop() {
It seems to be only reproducable with the audio board (USBStreamer) I am using to output TDM into the Teensy. When I am connecting the Teensy and TDM board to the PC (using an aux cable), the TDM output from the board works fine.
I'm struggling to even understand what hardware you're using and how you're connecting it to Teensy, not to mention what it's suppose to actually do.

When I search for USBStreamer, google turns up this page. Is this the hardware you're connecting to Teensy?


I don't understand how this could possibly be expected to work with Teensy in TDM mode. The datasheet says:

I2S/TDM format for input/outputs   24 bits I2S master mode
                                   Sample rate: 8/11.025/12/16/22.05/24k/32k/64k 44.1/48/88.2/96/176.4/ 192kHz
                                   TDM mode: 8ch @ 48k / input and output on I2S_data_in1/out1.

Teensy's TDM is also master mode. Obviously you can't connect 2 boards together if both are using master mode!
The goal of my project is to send TDM8 to the CS42448 board that you created on OshPark, then use the data to determine the gain levels in dBFS of each of the channels using Teensy's Design Tool. The amplifier I plan to send TDM on is a master. I was assuming since I am an audio novice that I could use connect my amplifier to the CS42448 board since that can be configured for TDM slave, and then maybe output that signal to the Teensy? Thanks so much for all of your help!
Is the "amplifier" that USBStreamer product? Or something else? I'm still confused by the description of intended hardware.

I can tell you Teensy's TDM is master mode, and the CS42448 chip is slave mode.

A common misunderstanding of these terms has come up with other threads on this forum, so maybe it's worthwhile to mention these I2S/TDM terms "master" and "slave" are *not* about the direction of data flow. They are about which side creates the clock signals. The master transmits the BCLK and FS(TMD mode) or LRCLK(I2S mode) clock signals, and sometimes also MCLK. The slave device receives those clock signals.

It is possible to connect 1 master device to 2 or more slave devices, assuming the master is electrically capable of driving the signal to multiple receivers (or buffer chips are used to strengthen the signal). But multiple masters can't be connected together, because each has its own clock signals.
No, the USBStreamer is just a product I was using to see if it was possible to receive the TDM input from. I am going to be using an actual audio amplifier in the future. Does the Teensy's MCU have configurations for TDM slave, or is it not possible whatsoever? The device that receives the data from my amp has to be a slave. Thanks again for the explanations.
Does the Teensy's MCU have configurations for TDM slave

The audio library only supports TDM in master mode.

or is it not possible whatsoever?

Slave mode is theoretically possible, but doing this would require writing the code to work in slave mode. This is not a beginner level task. But at least I2S slave mode exists in the library, so there is code to start.

I am going to be using an actual audio amplifier in the future. .... The device that receives the data from my amp has to be a slave.

Normally audio amplifiers take an analog signal input.

Do you really have an audio amp with TDM input? I've never seen such a product. If it does exist, I'd be curious to see a link to its info.
Thanks for the quick response. I am going to look into it. If I am able to make changes to the input_tdm.cpp file for slave mode, how would I be able to build the code to flash the Teensy?

The amp is able to receive the TDM input using the A2B protocol. It can be master or slave, but the master is outputting the data that I need.
If I am able to make changes to the input_tdm.cpp file for slave mode, how would I be able to build the code to flash the Teensy?

Arduino detects if you've changed or added files to the library. It automatically rebuilds the library for you. All you need to do is click Verify or Upload.
Thanks for the info. Are the variables such as "I2S_RCR2_BCD" located in the Audio repository? I am trying to change the register configurations. Thanks for your patience.
My last question is if I can able to read the peak values higher than 1? I was able to successfully calculate gain levels using the peak object but notice that I can only go up to 0 dB (1.0), and nothing further. Is it even possible to read values that are higher than that?
This is the convention used throughout all the public functions of the whole library. It's just 1 thing in a particular file!
One should perhaps explain that 16bit audio @44.1kHz does not give headroom for levels above 0dB if one intends to keep the THD and SNR at decent values. Although this resolution and sampling rate is great for an embedded system like the Teensy 3.2, it has to be understood that higher resolutions (24/32bit) and sampling rates (96/192kHz) are used for studio productions to allow for a dynamic headroom of +4 or even +8dB without sacrificing THD and SNR.

But even on the Teensy, if it‘s not for the least HiFi Detail, dividing the input signal by 4 with a 11k/33k resistor divider results in a « normal » level of -12dB or a peak value of 0.25. Multiplying the peak value by 4 (what we divided on the input signal before) will then allow for seeing peak values up to 4 or +12dB
Not open for further replies.