use input port as counter

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
pasau
Experienced Member
Posts: 77
Joined: Fri Dec 06, 2013 7:05 pm

use input port as counter

Post by pasau »

Hi, i've encountered something in the usb reference design that requires some sort of clarification. First, there is the output port from a certain PLL that is input to give a clock reference.

Code: Select all

/* Clock master clock-block from master-clock port */
    configure_clock_src(clk_audio_mclk, p_mclk_in);
Then this clock is used to clock an in port

Code: Select all

asm("ldw %0, dp[clk_audio_mclk]":"=r"(x));
asm("setclk res[%0], %1"::"r"(p_for_mclk_count), "r"(x));
But the port p_for_mclk_count, is not attached to anything, in fact it is declared as P16B, from which only the bit 15 is available on a pin on the u8-64-fb96. Im assuming they use the buffered port as a reference timer, since the port is never input and all the application ever does is getting the port timestamp. but why use a port for this purpose?


User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

What else would you use? The alternative is to count clock
edges "by hand", not such a hot idea.
User avatar
Ross
XCore Expert
Posts: 966
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

Annoyingly with the current architecture you can only get clock ticks out of a port (getts instruction) not a clock block...

The port isn't used for anything apart from getting the clock count out of the clock block. Any unused port could be used.
pasau
Experienced Member
Posts: 77
Joined: Fri Dec 06, 2013 7:05 pm

Post by pasau »

i get it thanks. In short it serves as a timer which can be driven by any clockblock, and not just the system clock?