Measuring short delays

Technical questions regarding the XTC tools and programming with XMOS.
JohnR
Experienced Member
Posts: 93
Joined: Fri Dec 11, 2009 1:39 pm

Measuring short delays

Post by JohnR »

Hi,

This is almost a continuation of an earlier thread but the question has changed a bit.

I am trying to measure very short delays with the code below

Code: Select all

start when pinseq(1) :> void; // @ tStart;
            tmr :> tStart;
           test <: 1;

         stop  when pinseq(1) :> void; // @ tStop;
           tmr :> tStop;
..........................
          delay = tStop - tStart;

If I use the commented out form of using the timing data directly from the port I get almost random data in the variable, delay. If I use separate reads of a single timer as in the code above all is well. The two ports are

in port start = XS1_PORT_1A;
in port stop = XS1_PORT_1B;

I had assumed that the two ports are supplied with the same reference clock but it almost looks as if each port has its own clock. Is this the case?

Thanks in advance for any help,

John.


User avatar
Andy
Respected Member
Posts: 279
Joined: Fri Dec 11, 2009 1:34 pm

Post by Andy »

This from the XS1 ports document should clarify:
Timers are 32-bit counters that are relative to the internal 100 MHz reference clock. Port counters are 16-bit counters clocked by either an external clock, or by a divided internal reference clock.
Concerning your timing problems, this could be the problem:
The port counter is incremented on falling edges of the clock. Note that the port counter simply counts clock edges on the input clock. A port counter counts in the application clock domain, and is only a measure of time if the input clock is a signal that has clock edges at regular intervals.
Hope it helps.
JohnR
Experienced Member
Posts: 93
Joined: Fri Dec 11, 2009 1:39 pm

Post by JohnR »

Hi Andy,

Thanks for your helpful response. I will certainly check into that.

Meanwhile I have been searching for a definition of the parameters given to the setclk call as used in the code fragment below, which is setting up one of my IN ports. What does the value 0x6 mean?



Code: Select all

   type  start, @object
          .section .dp.data,       "adw", @progbits
.cc_top start.data, start
          .align    4
start:
          .int      0x00010200
.cc_bottom start.data
          .align    4
          .section .globcode,      "ax",  @progbits
          .align    2
.LC0:
          ldw       r0, dp[start] 
          setc      res[r0], 0x8
          ldc       r1, 0x6
          setclk    res[r0], r1
          retsp     0x0 
          .section .ctors,         "aw",  @progbits
          .align    4
          .int      .LC0
          .section .globcode,      "ax",  @progbits
.LC1:
          ldw       r0, dp[start] 
          setc      res[r0], 0x0
          retsp     0x0 
          .section .dtors,         "aw",  @progbits
          .align    4
          .int      .LC1
All this is in aid of measuring short time differences. At the moment the smallest interval I can measure is about 60 nsecs which seems to be the time needed for a pulse at the input to be processed by the IN command?

Thanks for any help

John.