MC Audio and AVB/TSN

If you have a simple question and just want an answer.
User avatar
Sebastian
Member++
Posts: 25
Joined: Wed Jul 20, 2016 9:15 am

MC Audio and AVB/TSN

Postby Sebastian » Tue Mar 27, 2018 11:44 am

Hi every one,

I know, at the moment there are a lot of questions out there,
but maybe someone have some time to read mine.

I have two xCore-200 MC Audio (V2.0) boards for testing some AVB/TSN stuff.

Both boards are connected via cat6 cable with a lenght of 50cm.
MCLK and LRCLK of both boards are measured with an oszi.

//----| 1 |------
On first step I used the orginal AN00202_gige_avb_i2s_demo (last Commit: e21f951 from 10.Oct.2017),
without any customization of the code, except default_sample_rate in application_task and #define AVB_1722_1_CONTROLLER_ENABLED 1
=> 48kHz and 96kHz every thing works fine.
The oszi displays an synchronised and syntonized clock signal of both boards.

//----| 2 |------
On next step I tried to use 192kHz.
=> But LRCLK was only 160kHz.
Ok maybe is the I2S routine too slow, so I tried I2S_frame master.

Code: Select all

    //****************************************************************
    //                |  receive Data from ADC  |
    //****************************************************************
    case i2s.receive(size_t num_chan_in, int32_t sample[num_chan_in]):

                                         
      break;


    //****************************************************************
    //                |  send Data to DAC  |
    //****************************************************************
    case i2s.send(size_t num_chan_out, int32_t sample[num_chan_out]):
      unsafe {

          c_audio :> sample_out_buf;

          tmr :> p_in_frame->timestamp;
          audio_frame_t *unsafe new_frame = audio_buffers_swap_active_buffer(*double_buffer);
          c_audio <: p_in_frame;
          p_in_frame = new_frame;   
                                   
      }//unsafe


Now it was also possible to drive the I2S lines with 192kHz.
48kHz and 96kHz are still working with an AVB Talker/Listener connection.
But with 192kHz the media_clock_server are not able to get in lock.

//----| 3 |------
Next step I tried the boards with an Mac Mini (High Sierra 10.13.3).
With the OSx tool AVB Audio Configuration I opened a virtual AVB soundcard with 8 streams, 8ch each stream and 192kHz.
The MC-Audio board works succesfully as listener, also with 192kHz.
The Mac and the MC-Audio board where connected via PreSonus(SW5E Switch: I think there is an Marvel switch-ic inside)

//----| 4 |------
On last step I used debug_printf for watching the variables diff and sample_diff in media_clock_server.xc
The both MC-Audio boards were connected direktly like in step one. (Cat.6 with 50cm)

->48kHz
diff wobbles from -15 to +15 and sample_diff was always 0;
Looks great.

->96kHz
diff wobbles most of the time from -15 to +15, but somethimes "jumps" to -10000;
But sample_diff stayes always to 0.

->192kHz
b]diff[/b] stays the most time by round about -1800000 and sample_diff by -86;

->192kHz with Mac (like step: 4)
diff wobbles most of the time from -5000to +5000
(looks like an sinewave. A little bit like an to high proportional part of the PLL feedback control. But I'm not shure)
But sample_diff stayes always to 0.



We have several custom boards with the XEF232-1024 processor out there. Based on the MC-Auido with the CS2100 as clock.
So it would be really "lousy" to tell our customers that we could not deliver the 192kHz as AVB Talker.

If someone have an idea what aplication notes I could use, would be great.
On the other hand, could it be, that it is impossible to use the xCORE-200 for 192kHz talker?
I could really not imagine, because what should it make so much different to 96kHz?



Best regards,
Sebastian
User avatar
akp
XCore Addict
Posts: 196
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Tue Mar 27, 2018 12:24 pm

When you say you are using 192kHz, 8 streams, 8 ch/stream is that for one board or two? I am pretty sure the most that's feasible with MC Audio board is 192kHz, 1 stream, 8ch/stream (i.e. total 8 ch in & 8 ch out) if you are using the ADC and DAC, but perhaps you are synthesizing additional channels?

I believe the most I have had working well as a talker with one MC Audio board is 192kHz x 1 stream x 8ch/stream but I only use 100Mbps in my product to reduce wiring (2xUTP rather than 4xUTP). So perhaps I am Ethernet bandwidth limited and the board could handle more, I don't know. I too have seen the ~160kHz clock but I kind of forget how I solved it, it was a few months ago.

Have you tried setting the clock source to local clock rather than input stream defined? Even the non-frame master I2S code will have no problem with 192kHz x 4 I2S lanes i/o (i.e. 8ch in/8 ch out). I think you only need frame master if you want 384kHz x 4 I2S lanes i/o; the regular I2S code seems to handle only a total of 6 ins+outs at 384kHz (and might need a high prio core for that) according to my simulation results. I run my boards as talker only with local clock only.

I have had other problems with 192kHz AVB:
1. The mid 2012 MacBook Pro I was using to test would not work with 192kHz stream running MacOS High Sierra (I had a build with the spectre/meltdown fixes). I reverted to pre-spectre/meltdown El Capitan and 192kHz worked OK with that.
2. There is a race condition in the talker double buffering that shows up at 192kHz frame rate. It caused me to drop one 192kHz x 4 ch frame every 5-20 seconds (depending on optimizations elsewhere). No frame drops once I replaced the double buffer with a fifo. The fifo should be provisioned for > 4 frames according to my testing. That took me a couple days to figure out with help from a second set of eyes. Maybe I would generate a pull request if XMOS cared, but I don't know if they do.

Also check out my posts showing how I fixed an out of order sample race condition if you use multiple talker streams.
User avatar
Sebastian
Member++
Posts: 25
Joined: Wed Jul 20, 2016 9:15 am

Postby Sebastian » Tue Mar 27, 2018 1:37 pm

Hello akp,

thanks for your answer.

When you say you are using 192kHz, 8 streams, 8 ch/stream is that for one board or two? I am pretty sure the most that's feasible with MC Audio board is 192kHz, 1 stream, 8ch/stream (i.e. total 8 ch in & 8 ch out) if you are using the ADC and DAC, but perhaps you are synthesizing additional channels?

Oh no, sorry there was an misunderstanding.
The MC-Audio board works with 1Stream and 8ch. So the orginal AN00202_gige_avb_i2s_demo without any custom code.
I configured the Mac Mini whith that AVB Config as an virtual AVB-Soundcard with AVB Audio Configuration.
The tool is not documented anywhere, but you could find it at /System/Library/CoreServices/
I think El Capitan (10.11) or later.

Have you tried setting the clock source to local clock rather than input stream defined?

Yes I did, but it doesn't solv the problem.

2. There is a race condition in the talker double buffering that shows up at 192kHz frame rate. It caused me to drop one 192kHz x 4 ch frame every 5-20 seconds (depending on optimizations elsewhere). No frame drops once I replaced the double buffer with a fifo. The fifo should be provisioned for > 4 frames according to my testing. That took me a couple days to figure out with help from a second set of eyes.

I think that I had nearly the same phenomenon a year ago. But I really don't know, which version of the tsn_lib I was using.

Maybe I would generate a pull request if XMOS cared, but I don't know if they do.

I hope they do.
In the worst case, I have to look for an other processor type.

Who is online

Users browsing this forum: No registered users and 18 guests