LRCLK as port Clock?

If you have a simple question and just want an answer.
Maran
Junior Member
Posts: 6
Joined: Wed Nov 19, 2014 4:48 pm

LRCLK as port Clock?

Post by Maran »

Hey,

how can I set the clock of a single port to the lrclk within using the USB Audio 2.0 (2iomx)?(44.1kHz)

 

Thank you for any replies! 

User avatar
infiniteimprobability
Verified
XCore Legend
Posts: 1164
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Yes,

this should be possible. You will need to connect the LRCLK port to a clock block, and then clock your new port from this clock block. This means you will need a spare clock block, which you do have on 2iomx (XS1_CLKBLK_1)

The scheme will be in the same manner as clocking p_bclk below (see USB audio design guide section 3.5.1)



 

The code will be something like this:

on tile[0]:  clock clk_lrclk   = XS1_CLKBLK_1;

on tile[0] : port p_clocked_by_lr    = <my port>;
 
set_clock_src(clk_lrclk, p_lrclk); //Make clkblk take clock from LRCLK port
set_port_clock(clk_lrclk, p_clocked_by_lr);       //Use this clock to clock our new port
start_clock(clk_lrclk);
 

Check the API for the above in xs1.h to make sure you are totally happy with what they are doing (or look at https://www.xmos.com/download/public/In ... 38B%29.pdf). Maybe run a quick experiment to make sure this does what you want.
 
I haven't checked this and you may run into the compiler stopping you from being a bit cautious and re-using ports. 
 
 
If you do run into compiler issues (re-using the same port for a clock input, which should actually be OK), then look at main.xc in the USB audio guide to see an exmple of working around this (eg. 
/* Uses same clock-block as I2S */
            asm("ldw %0, dp[clk_audio_mclk]":"=r"(x));
            asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x));
)
or call it from a C file..
 
Engineer at XMOS
Maran
Junior Member
Posts: 6
Joined: Wed Nov 19, 2014 4:48 pm

Post by Maran »

Thank you, it really works.

My problem now is, that I not only need the original clock of the lrclk but a multiple of it.

Is there any opportunity to get this?