being a newbie on XMOS I want to understand how to transfer audio data (to write the code) from a while(1) loop that reads I2S data to another thread (while(1) loop) that sends the I2S data. (24bits, Wclk = 64 BitClks)
The characteristic is that both threads are frequency and phase locked. In other words: Both threads have theire individual input pins for WordClock and BitClock but externally these pins are shorted.
The output thread looks like this:
Code: Select all
void OutThread (chanend adc_to_aes)
{
.... init bla bla
while(1)
{
set_thread_fast_mode_on();
int dummy[2];
while(1)
{
// output 24 bits on the rising or falling edge of the word clock (lrck)
// note lr == 0 is right channel, lr == 1 is left channel
dac_lrck when pinsneq(lr) :> lr @ t;
switch(state[SOURCE_STATE])
{
case AES_MUTE:
.....
break;
default:
t += 33;
if(lr == 0)
{
partout_timed(io_i2s[0], 24, dummy, t);
adc_to_aes :> dummy[0];
}
else
{
partout_timed(io_i2s[0], 24, dummy, t);
adc_to_aes :> dummy[1];
}
break;
} // end switch(source)
}
Code: Select all
while(1)
{
int anabuf[2];
set_thread_fast_mode_on();
while(1)
{
adc_lrck when pinsneq(lra) :> lra @ ta;
ta +=24;
asm("setpt res[%0], %1" :: "r"(adc_data), "r"(ta));
if(lra == 0)
{
asm("in %0, res[%1]" : "=r"(anabuf[0]) : "r"(adc_data));
adc_to_aes <:anabuf[0];
}
else
{
asm("in %0, res[%1]" : "=r"(anabuf[1]) : "r"(adc_data));
adc_to_aes <:anabuf[1];
}
}
}
Can anybody tell my WHY this does not work?
Do I really have to go over 'shared' 'unsafe' memory?
Why can't I use a normal channel for the tranfer 'chanend adc_to_aes' to do this job?
(Remembering both threads are full synchronous and phase locked)
What do I NOT understand?
MANY THANKS!