I2S slave sync problem Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
andreaalbano
Member
Posts: 10
Joined: Tue May 31, 2016 3:00 pm

I2S slave sync problem

Post by andreaalbano »

Hello everyone,
I found a problem on the I2S slave code: the stream is synchronized with the WCLK only at the beginning and in the wrong mode. In fact, if the WCLK is already running, the synchronization is not assured.
To handle this I've modified the code in i2s_slave_impl.h from this

Code: Select all

      
        m = config.mode;

        clearbuf(p_lrclk);

        p_lrclk when pinseq(0x80000000) :> int @ port_time;
        port_time += (m == I2S_MODE_I2S);

  
        for(size_t i=0;i<num_out;i++)
            p_dout[i] @ port_time + 32+32  <: bitrev(i2s_i.send(i*2));
to this

Code: Select all

        m = config.mode;

        clearbuf(p_lrclk);

        p_lrclk when pinseq(0x80000000) :> int @ port_time;
        port_time += (m == I2S_MODE_I2S);
        p_lrclk when pinseq(0x7FFFFFFF) :> int @ port_time;
        port_time += (m == I2S_MODE_I2S);
        p_lrclk when pinseq(0x80000000) :> int @ port_time;
        port_time += (m == I2S_MODE_I2S);

        for(size_t i=0;i<num_out;i++)
            p_dout[i] @ port_time + 32+32  <: bitrev(i2s_i.send(i*2));
The problem still persist if the WCLK for some reason change and the i2s is not restarted.
I think that a good I2S library should check for the falling edge of the word clock at every cycle.

I thought to put some check inside the loop, maybe before i2s_i.restart_check();

Code: Select all

        while(restart == I2S_NO_RESTART){
  
            i2s_slave_receive(i2s_i, p_din, num_in, 0);

            i2s_slave_send(i2s_i, p_dout, num_out, 0);


            i2s_slave_receive(i2s_i, p_din, num_in, 1);

            i2s_slave_send(i2s_i, p_dout, num_out, 1);

            restart = i2s_i.restart_check();

        }
Unfortunately I'm a Xmos beginner and any attemp I did failed.
Can anyone help me with this?

Many thanks in advance,
Andrea
View Solution
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

Hi Andrea,

There are some known bugs with the i2s slave component which will be fixed with release 2.2.0 of lib_i2s. This release has not been made yet, but it is available in git. Can you try that to see whether it fixes the issue you are seeing (lib_i2s repo)?

Regards,

Peter
andreaalbano
Member
Posts: 10
Joined: Tue May 31, 2016 3:00 pm

Post by andreaalbano »

Hi Peter,
yes it is exactly what I meant.
I've just tried it and seems 100% working. Also looking at the code it seem to do exactly what I expect.

Thanks a lot,
Andrea