The program below is a simple test for this:
Code: Select all
on tile[0] : out buffered port:32 p_dout[2] = {XS1_PORT_1M, XS1_PORT_1N};
on tile[0] : in buffered port:32 p_din[2] = {XS1_PORT_1I, XS1_PORT_1J};
on tile[0] : port p_mclk = XS1_PORT_1F;
on tile[0] : out buffered port:32 p_bclk = XS1_PORT_1H;
on tile[0] : out buffered port:32 p_lrck = XS1_PORT_1G;
on tile[0] : clock mclk = XS1_CLKBLK_2;
on tile[0] : clock bclk = XS1_CLKBLK_3;
{
configure_clock_src(mclk, p_mclk);
configure_clock_src_divide(bclk, p_mclk, 5);
configure_port_clock_output(p_bclk, bclk);
configure_out_port_no_ready(p_lrck, bclk, 0);
configure_out_port_no_ready(p_dout[0], bclk, 0);
configure_in_port_no_ready(p_din[0], bclk);
start_clock(mclk);
start_clock(bclk);
unsigned bclk_lrck_ratio = 25;
unsigned Lch_sample = bitrev(0x01AC6B4D);
unsigned Rch_sample = bitrev(0x01296479);
unsigned rev_sample = 0;
while(1)
{
rev_sample = partin(p_din[0], bclk_lrck_ratio);
partout(p_lrck, bclk_lrck_ratio, 0x01000000);
partout(p_dout[0], bclk_lrck_ratio, Lch_sample);
printf("rev sample = 0x%.8X\n", bitrev(rev_sample));
rev_sample = partin(p_din[0], bclk_lrck_ratio);
partout(p_lrck, bclk_lrck_ratio, 0x00FFFFFF);
partout(p_dout[0], bclk_lrck_ratio, Rch_sample);
printf("rev sample = 0x%.8X\n", bitrev(rev_sample));
}
}
However, I just can get 0x01FFFFFF or 0x00000000 in console view all the time.
I'm not sure if this is a bug? If yes, how to implement the partin() function with inline assembly?
Any idea will be appreciated!
Updated:
I guessed 'printf' affected I2S timing, so the program above will never get the correct value.
I changed the 'while(1)' loop as follows, and this time I got 0x01AC6B00 back from 'p_din[0]':
Code: Select all
while(1)
{
rev_sample = partin(p_din[0], bclk_lrck_ratio);
partout(p_lrck, bclk_lrck_ratio, 0x01000000);
partout(p_dout[0], bclk_lrck_ratio, Lch_sample);
rev_sample = partin(p_din[0], bclk_lrck_ratio);
partout(p_lrck, bclk_lrck_ratio, 0x00FFFFFF);
partout(p_dout[0], bclk_lrck_ratio, Rch_sample);
printf("rev sample = 0x%.8X\n", bitrev(rev_sample));
while(1){}
}