• 1

TDM Protocol with Digital Discovery


I am trying to interface a MEMS microphone ICS-52000 with the Digital Discovery board.  The microphone outputs data using Time Domain Multiplexed (TDM) signaling. TDM is somewhat similar to I2S but without the left and right channel.  The Digital Discovery board has I2S listed under Logic.  I want to make a Protocol for TDM.  Is it possible to use the Digital Discovery board to develop a protocol that will generate a clock signal (output) along with a word select (output) synchronous to the clock signal and then read data (input) from a connected microphone?  Data would be streamed to a file.



Share this post

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi @Douglas

The attached project generates SCK/WS signals on DIO25/24, 64/1 clocks from 128 custom samples at 6.25MHz, 48.8khz sample rate. Remove the DIO26 from pattern and connect it to SD. The Logic Analyzer is configured to store the SCK transitions and custom interpreter to decode the first 24 SD bits on SCK falling edge after WS. To see only the decoded data open View/Events and select TDM. This data can also be exported.
With this method you could record up to 500k samples. The decoding of such number of samples (64M raw data) with custom script could take a few minutes.
For longer streaming to file a custom application based on WaveForms SDK is needed.




// rgData: input, raw digital sample array
// rgValue: output, decoded data array
// rgFlag: output, decoded flag array

var c = rgData.length // c = number of raw samples
var pClock = false; // previous cock signal level
var iStart = 0;     // used to keep track on word start index
var cByte = 0;      // byte count per transmission
var cBits = -1;     // bit counter
var bValue = 0;     // value variable

for(var i = 0; i < c; i++){ // for each sample
    var s = rgData[i]; // current sample
    var fSelect = 1&(s>>0); // pin0 is the select signal
    var fClock = 1&(s>>1); // pin1 is the clock signal
    var fData = 1&(s>>2); // pin2 is the data signal
    if(pClock==fClock) continue; // no clock edge
    pClock = fClock; // previous clock level

    if(fClock==0 && cBits>=0 && cBits<24){ // sample data on clock falling edge, first 24 bits
        bValue <<= 1; // serial data bit, MSBit first
        if(fData)  bValue |= 1;
    if(fClock!=0 && fSelect!=0){ // select high on clock rising edge
        if(cBits>0){ // store earlier collected data
            // store rgValue/Flag from word start index to current sample position
            for(var j = iStart; j < i; j++){
                // Flag change will be visible on plot even when data remains constant.
                // This is useful in case we get more consecutive equal values.
                rgFlag[j] = cByte;
                rgValue[j] = bValue;
        // reset our counters/variables
        iStart = i;
        cByte = 0;
        cBits = 0;
        bValue = 0;

Value to Text for hex:

// value: value sample
// flag: flag sample

function Value2Text(flag, value){
    case 0: return "X";
    default: return "0x"+value.toString(16)


Share this post

Link to post
Share on other sites
  • 0
On 10/13/2017 at 2:49 AM, attila said:

Hi @Douglas

I just notice the I2S decoder can also process TDM data and decoding with this is much faster.
Just add a filter to the Event view to show the values for one channel, like starts with L.






I loaded up tdm2 that you provided above, ran it on my hardware, and captured some data with my oscilloscope.  Interestingly, with the Parameter1 setting of 6.25MHz provided in tdm2 SCK (DIO25) outputs at 3.125MHz as shown in the first screen shot. 


If I increase the bus frequency of Parameter1 to 12.5MHz then SCK outputs at 6.25MHz, however, if I leave the sample size in the bus settings at 128, Select (DIO24) outputs at 96kHz.  In screen shot below Parameter1 is set to 12.5MHz and I have edited the bus increasing the sample size to 256.  I now get Select outputting at 48kHz but SCK is zero half the time.

What am I missing in the configuration settings that I need to set to get SCK to output continuously?




Edited by Douglas

Share this post

Link to post
Share on other sites
  • 0

Hi Attila,

I'm actually working with Doug on this project.

I managed to get an AD2 driving the microphones and reading the bitstream in a similar manner as you suggest, but the I2S decoder can only gather the samples for the first microphone. Our development boards have 4x mics, and we eventually want to go up to the max of 16x.

I tried adjusting the I2S parameters so that I could grab multiple microphones at a time (e.g. mics 1+2 in L channel, 3+4 in R channel), and then parse them myself afterwards, but could not set the word length greater than 32 - I would need 64 for each channel to get the 2x 32-bit windows for each mic pair.

I looked inside the Waveforms application to see if the I2S decoder script was available for me to duplicate/modify for our purposes, but did not see something like that.

Do you know if/where that might be available?


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now