How to view the value of sample read by i2s bus?

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
Active Member
Posts: 48
Joined: Fri Mar 16, 2018 2:30 pm

How to view the value of sample read by i2s bus?

Postby cjf1699 » Tue Apr 10, 2018 10:28 am

Dear everyone,
I have had a really hard time debugging with the example , AN00162 ,on my board:
xCORE-200 Multichannel Audio Platform. This example creates a digital audio loopback on the XMOS multicore microcontroller. What I want to do is to observe the value of sample read and sent by i2s bus, which is really simple. However, I have tried a few different ways under the help of various documents on XMOS site, including
A:debug with real-time printing;
B: the offline mode of the xscope;
C: the real-time mode of the xscope, and even xgdb using the command line.

Unfortunately, these listed methods all failed. The following is the related code section:
When I tried to use method A, the console kept outputting 0 and the input music couldn’t be looped back. We could hear nothing from the speaker, and the output result was wrong, either.

When I tried to use method B, again, we can hear nothing from the speaker but a buzz . When I stopped the project, the trace perspective showed below:

When I tried to use method C, except for the trace perspective after pressing the stop button(showed below), everything was the same: nothing but a buzz could be heard , which seems to mean that the music can’t be looped back with no matter what debug method being used.

In the picture above, 2 straight lines whose values were both 0 , were blinking.

The other day it occurred to me that the maybe I could use the LED arrays on the board to examine the value of “sample”. I added "if" conditions like this in the case receive and send:

Code: Select all

       case i2s.receive(size_t index, int32_t sample):
      samples[index] = sample;

      if(sample != 0){              //turn on D25
          led_row <: 0x7;
          led_col <: 0x8;

     // xscope_int(0, sample);

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

      if(sample != 0){              //turn on D10
               led_row <: 0xE;
               led_col <: 0x1;


However, regardless of the “if” condition(sample == 0; sample != 0; sample > 0; sample < 0), the same thing happened. The specified LED was always on. That’s to say, I failed to know about the value of “sample” again….
Now, I don’t know what to do. What’s wrong on earth? I attached the project and I would be grateful if anyone can help me.
Thanks a lot!
(1.52 MiB) Downloaded 31 times
(1.52 MiB) Downloaded 31 times
User avatar
XCore Legend
Posts: 1158
Joined: Thu Jun 10, 2010 11:43 am

Postby mon2 » Tue Apr 10, 2018 11:01 pm

In your LED method of testing...

if the LED is ON then the test condition is TRUE. So it is possible that the LED will be ON or even multiple LEDs will be ON if that condition is true.

To debug, apply the while(1); after the LED turns ON. Then run. No audio but if the LED turns ON then that condition is true. You could even hard code the value of sample variable to force the condition to fail to verify the logic is correct.

Who is online

Users browsing this forum: No registered users and 29 guests