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));
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));
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();
}
Can anyone help me with this?
Many thanks in advance,
Andrea