How to use chan to transmit a value in audio_i2s.h file

Technical questions regarding the XTC tools and programming with XMOS.
oyhp052
Member++
Posts: 16
Joined: Fri Jun 01, 2012 7:01 am

How to use chan to transmit a value in audio_i2s.h file

Post by oyhp052 »

Hi,
please help me , when someone see this forum .
I'm developing an AVB project , based on xmos app_xr_avb_lc_demo . And I want to design a headphone jack which could select channel .

in xr_avb_demo.xc file :
when I established a connection between thread demo( ) and thread i2s_master() by use of a chan (named monitor_ch), and codes as follow :

in sw_avb/app_xr_avb_lc_demo/src/xr_avb_demo.xc file :

Code: Select all

void  demo (.. , chanend monitor_ch , ... );     ---- thread
{
...
	  monitor_ch <: ch ;
	  monitor_ch <: val ;
...
}

in sw_avb/module_avb_audio/src/interfaces/i2s/audio_i2s.h
inline void  i2s_master( .. , chanend monitor_ch, .. );   ---- thread
{
...

while (1)
{
	      monitor_ch :> monitor_set ;                // Expected value 1
	      monitor_ch :> monitor_val ;                // Expected value 2
...
        if (k < num_out>>1) {
          unsigned int sample_out;
          c_listener :> sample_out;
          sample_out = bitrev(sample_out << 8);
#pragma xta endpoint "i2s_master_sample_output"
          p_dout[k] <: sample_out;                          //this 4 GPIO output avb audio

if (k==monitor_val)                       // use the monitor_val to change headphone jack channel
         monitor_ch_audio<: sample_out;                 //the headphone jack output GPIO
...
}
}
And bug as follow :
1. when I remove the 2 lines and set the monitor_val :
// monitor_ch :> monitor_set ; // Expected value 1
// monitor_ch :> monitor_val ; // Expected value 2
...
if (k==0)
monitor_ch_audio<: sample_out;

Compile and debug the project , then the 4 GPIO output avb audio successful and can listen to the 1 channel's output avb audio, but I can not get the 2 expected value and to select headphone jack channel .

2. when I don't make any changle of the code above :
Compile and debug the project, then I can get the 2 expected val (monitor_set and monitor_val) by use "printstr( ) " and "printhex( )" via XTAG-2 . However , the 4 GPIO can't output avb audio any more , and the monitor_ch_audio GPIO can't output headphone jack audio also . I think maybe the 2 lines destroyed the i2s timing or clock , is this ? what should I do ? Could you give me some Suggestions?

Thanks


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

Added coded tags around your code to make it more readable.

Print statements can halt the core so it shouldn't be used on cores running timing critical code
oyhp052
Member++
Posts: 16
Joined: Fri Jun 01, 2012 7:01 am

Post by oyhp052 »

Bianco wrote:Added coded tags around your code to make it more readable.

Print statements can halt the core so it shouldn't be used on cores running timing critical code
ok , thank you . The code of audio_i2s.h as follow.
You do not have the required permissions to view the files attached to this post.
oyhp052
Member++
Posts: 16
Joined: Fri Jun 01, 2012 7:01 am

Post by oyhp052 »

Bianco wrote:Added coded tags around your code to make it more readable.

Print statements can halt the core so it shouldn't be used on cores running timing critical code
Hi Bianco,
Could you help me and give me some advise ,please? Thank you .
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

As Bianco stated, don't use prints in something that needs to run in real time. It interrupts the processor and accessed via JTAG.