Problems getting started with xCORE-200 MC AUDIO

Technical discussions related to any XMOS development kit or reference design. Eg XK-1A, sliceKIT, etc.
sukandar
Member
Posts: 11
Joined: Thu Jun 20, 2013 3:31 pm

Problems getting started with xCORE-200 MC AUDIO

Postby sukandar » Tue Jan 26, 2016 4:35 am

Dear forum,
I'm having problems making any progress in learning how to program for the xCORE-200 MC AUDIO. What's working fine so far are the two specific application notes for the board - AN00202 and AN00203, which build and run OK. I have also managed to get some LEDs blinking and the other examples from the programming guide work too.

As a first simple task I then set out to write a feedthru program for the analog audio I/O, however so far I have failed. At first I tried to strip down the above ANs from their Ethernet functionality and route the input to the output thru a streaming channel. Then I tried to modify the Audio Effect Demo for the startKIT (AN00201) by changing the initialization routines for the Codec/converters as well as port mappings and other details.
In both cases I only got a short click on the audio outputs. Looking at the bit&word clock signals, I see pulses for about 350ms, then it stops. MCLK signal is fine though.
When I suspend the debugger, I see three active cores (when running the modified AN00201): the wavegen, the audio effect, and the i2s_master. The latter seems to be constantly in some "restart" routine which I don't quite get...

Are there maybe any further intermediary examples between the simple LED blinking and the (currently) intimidating complexity of the AVB application notes? In particular something specific to my board, as I suspect it's not the XMOS cores as such, but the system dependencies between the CPU and the peripherals that cause these problems.

Thanks for any suggestions,
Sukandar
User avatar
infiniteimprobability
XCore Legend
Posts: 1124
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Tue Jan 26, 2016 10:13 am

Yes - Blinky to AVB is a bit of a jump. There *should* be a loopback example in lib_i2s. It's a pretty common requirement for a starting point which is why it was written - and it's ported for this board so you can concentrate on your app rather than the framework. However, I can't find it on the website. Apologies...And thanks for raising this.

PM me and I'll send you the source to get you going. In parallel we'll work out why that hasn't got pushed and make sure it appears in the "examples" tab of the tools IDE, as it should do.
sukandar
Member
Posts: 11
Joined: Thu Jun 20, 2013 3:31 pm

Postby sukandar » Tue Jan 26, 2016 5:30 pm

worked great - thanks a bundle!

(will now try to figure out what exactly I did wrong)
sukandar
Member
Posts: 11
Joined: Thu Jun 20, 2013 3:31 pm

Postby sukandar » Tue Jan 26, 2016 6:56 pm

OK, turns out I was quite close with my own code, but somehow missed to connect the audio-effect's gain parameter/channel to a proper source.
I guess I thought because I didn't use the gain inside the audio-effect (yet), it wouldn't matter.

thanks again,
Sukandar
User avatar
infiniteimprobability
XCore Legend
Posts: 1124
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Fri Feb 05, 2016 5:06 pm

The Example (and brand new app note) are available to all now!

Find them http://www.xmos.com/support/appnotes/AN00162 on the website or using the examples view in xTimeComposer
Screen Shot 2016-02-05 at 16.04.30.png
Enjoy!!
You do not have the required permissions to view the files attached to this post.
User avatar
ccrome
Active Member
Posts: 60
Joined: Wed Sep 23, 2015 1:15 am

Postby ccrome » Fri Feb 05, 2016 5:06 pm

infiniteimprobability wrote:The Example (and brand new app note) are available to all now!

Find them http://www.xmos.com/support/appnotes/AN00162 on the website or using the examples view in xTimeComposer
Screen Shot 2016-02-05 at 16.04.30.png
Enjoy!!

Strange, when I import it, it looks right. I can see it in the Audio Examples. However, when I attempt to actually import it and click the 'Finish' button, it doesn't actually import into the workspace. Every other example I've tried so far has worked.

Also, the Project Name (i2s_loopback_demo) doesn't really match the AN title (Using the |I2S| Library).

Perhaps the strange AN title with the vertical bars can't be imported nicely into a workspace?


-Caleb
User avatar
infiniteimprobability
XCore Legend
Posts: 1124
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Mon Feb 08, 2016 2:58 pm

Yes - that does seem to be a bit broken. Apologies. Let us check on what's wrong but it may be the odd bar character indeed..

In the mean time you can download from here:

https://www.xmos.com/support/appnotes/AN00162
User avatar
infiniteimprobability
XCore Legend
Posts: 1124
Joined: Thu May 27, 2010 10:08 am

Postby infiniteimprobability » Thu Apr 07, 2016 11:45 am

Just to let anyone following this thread know that AN00162 imports OK now.
paolovecchiotti
Junior Member
Posts: 6
Joined: Tue Mar 15, 2016 5:00 pm

Postby paolovecchiotti » Thu Jun 16, 2016 3:07 pm

Hello to every one,

I am working on the XMOS 200 MC AUDIO. I am trying to merge the code of AN00162, the i2s loopback, which is actually working, with the code of AN00201, which is for the Startkit board.

What I did is quite linear. In a new project I copied the main of the project AN00162. Successively I copied from AN00201 the header and .xc file of "biquad" and "audio_effects".
After several tries I also decided to don't use the biquad filtering, and just apply a simple pass-through procedure exploiting the streaming chanend.

The i2s_loopback function becomes my_i2s, and it's written this way.

Code: Select all


[[distributable]]
void my_i2s_loopback(server i2s_callback_if i2s,
                  client i2c_master_if i2c,
                  client output_gpio_if dac_reset,
                  client output_gpio_if adc_reset,
                  client output_gpio_if pll_select,
                  client output_gpio_if mclk_select,
                  streaming chanend c_dsp)
{
        int32_t in_samps_main[8] = {0};
        int32_t out_samps_main[8] = {0};

  while (1) {
    select {
    case i2s.init(i2s_config_t &?i2s_config, tdm_config_t &?tdm_config):
      i2s_config.mode = I2S_MODE_I2S;
      i2s_config.mclk_bclk_ratio = (MASTER_CLOCK_FREQUENCY/SAMPLE_FREQUENCY)/64;

      // Set CODECs in reset
      dac_reset.output(0);
      adc_reset.output(0);

      // Select 48Khz family clock (24.576Mhz)
      mclk_select.output(1);
      pll_select.output(0);

      // Allow the clock to settle
      delay_milliseconds(2);

      // Take CODECs out of reset
      dac_reset.output(1);
      adc_reset.output(1);

      reset_codecs(i2c);
      break;

    case i2s.receive(size_t index, int32_t sample):
      if (index == 0) {
        for (size_t i = 0; i < 8; i++) {
          c_dsp <: in_samps[i];
          c_dsp :> out_samps[i];
        }
      }
      in_samps[index] = sample;
      break;

    case i2s.send(size_t index) -> int32_t sample:
      sample = out_samps[index];
      break; 

    case i2s.restart_check() -> i2s_restart_t restart:
      restart = I2S_NO_RESTART;
      //printf("codecs restarted\n");
      break;
    }
  }
}

The main becomes

Code: Select all

int main()
{
    streaming chan c_aud_dsp, c_debug;
//    chan c_gain;
  interface i2s_callback_if i_i2s;
  interface i2c_master_if i_i2c[1];
  interface output_gpio_if i_gpio[4];
  par {
    on tile[0]: {
      /* System setup, I2S + Codec control over I2C */
      configure_clock_src(mclk, p_mclk);
      start_clock(mclk);
      i2s_master(i_i2s, p_dout, 4, p_din, 4, p_bclk, p_lrclk, bclk, mclk);
    }

    on tile[0]: [[distribute]] i2c_master_single_port(i_i2c, 1, p_i2c, 100, 0, 1, 0);
    on tile[0]: [[distribute]] output_gpio(i_gpio, 4, p_gpio, gpio_pin_map);

    /* The application - loopback the I2S samples */
    on tile[0]: my_audio_effects(c_aud_dsp, 8); //changed

    on tile[0]: [[distribute]] my_i2s_loopback(i_i2s, i_i2c[0], i_gpio[0], i_gpio[1], i_gpio[2], i_gpio[3], c_aud_dsp); //changed

  }
  return 0;
}
Then I reduced my_audio_effects to the bone, becoming:

Code: Select all

void my_audio_effects(streaming chanend c_dsp,
        static const size_t num_chans)
{
  // Unprocessed input audio sample buffer
  int32_t in_samps[num_chans] = {0};

  // Sample buffer to hold samples after processing
  int32_t out_samps[num_chans] = {0};

  //int32_t gain = 0; // Start with volume at 0
  int32_t gain = 1;

  biquad_state_t biquad_state[num_chans];

  int cur_effect = 5+1; // This value is either 0 (meaning no effect should
                      // be applied) or a value representing one more than
                      // an effect type value as decribed by the enum in
                      // biquad.h
//  debug_printf("Biquad effect off\n");
//  i_led.set_multiple(0b111111111, LED_OFF);

  while(1) {
    // Send/Receive samples
    for (size_t i = 0; i < num_chans; i++) {
      c_dsp :> in_samps[i];
      c_dsp <: out_samps[i];
    }

//    xscope_int(LEFT_IN, in_samps[0]);
//    xscope_int(LEFT_OUT, out_samps[0]);
//    xscope_int(GAIN, gain);

        select{
        default:
            break;
        }
    for (size_t i = 0; i < num_chans; i++) {
    out_samps[i] = in_samps[i];
}


  }
}
Compared to the original file I removed the DSP processing, and the apply_gain function.

My idea is to just send data over the c_dsp channel acting as a pass-through.

However it does not work, and I am not able to understand where the problem lies.

Thank you for support.
paolovecchiotti
Junior Member
Posts: 6
Joined: Tue Mar 15, 2016 5:00 pm

Postby paolovecchiotti » Tue Jun 28, 2016 10:57 am

I answer myself. By means of Xscope offline view, I managed to find where my audio streams were lost. It was a indexes problem, plus a casting issue.

The streaming chanend works perfectly.

Who is online

Users browsing this forum: No registered users and 1 guest