delay between audio channels with SliceKit and loopback

Technical questions regarding the XTC tools and programming with XMOS.
chrbo
Junior Member
Posts: 6
Joined: Thu Nov 07, 2013 9:42 am

delay between audio channels with SliceKit and loopback

Post by chrbo »

Hello everyone,

a fellow student and me are using the SliceKit und the AudioSlice for an university project. For the Audio I/O we're using the I2S master from the GitHub repository.
By verifying our implementation i recognized a delay of exactly 1 sample between the left and right audiochannel, channel 1and 2 on the AudioSlice. At first i thought the problem is in our code, but didn't find anything. So i tried the loopback demo and measured the same thing with the oscilloscope. Did anyone else notice this behaviour? Is there a solution?

Best regards and thanks in advance,
chrbo


User avatar
lilltroll
XCore Expert
Posts: 956
Joined: Fri Dec 11, 2009 3:53 am
Location: Sweden, Eskilstuna

Post by lilltroll »

I have not examined the slice-kit myself, but I earlier had a similar problem earlier with a different board.

The error was in the LR pin on the I2S vs the feeding channel stream.

Check the datasheet for the CODEC.

If the CODEC should have I2S_LR=hi=left ??? and after that LR=lo=right ??? (to be verified in the datasheet), for one stereo output sample you need to send the left and right during that period.

Code: Select all

Chanend -> L[0] , R[0] , L[1] , R[1] , R[2] , L[2]
LR pin  -> Hi   , Lo   , Hi   , Lo   , Hi   , Lo   
sample  ->|            |             |             |
If everything is half a period to late or to early you can end up with

Code: Select all

Chanend -> R[0] , L[1] , R[1] , L[2] , R[2] , L[3]
LR pin  -> Hi   , Lo   , Hi   , Lo   , Hi   , Lo   
sample  ->|            |             |             |
In the last example one audio channel would come out 1 sample to late and the channels would be reversed.

This is just a suggestion for you to examine.

PS. If you find that something is incorrect with the samples and/or that the channels are reversed. File an ticket to XMOS so they can fix it ASAP. DS.
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Thanks for raising a github issue on this one, I will take a look
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Please try swapping these two lines and let us know how you get on:

Code: Select all

        // drive word clock
        p_lrclk <: 0xffffffff;

Code: Select all

        /* Output LR clock value to port */
        p_lrclk <: 0;
chrbo
Junior Member
Posts: 6
Joined: Thu Nov 07, 2013 9:42 am

Post by chrbo »

i've swapped it, but didn't change anything. I also downloaded and imported the latest verions of sc_i2s and sc_i2c. By the way, the Codec ID device check in audio_hw.xc

Code: Select all

 /* Read CODEC device ID to make sure everything is OK */
IIC_REGREAD(CODEC_DEV_ID_ADDR, data);

    codec_dev_id = data[0];
    if (((codec_dev_id & 0xF0) >> 4) != 0xC)
    {
        printstr("Unexpected CODEC Device ID, expected 0xC, got ");
        printhex(codec_dev_id);
    }
doesn't work anymore because the i2c_master_read_reg() has been removed from module_i2c_single_port. I'll open an issue int the repository.
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

This should now be fixed in sc_i2s