Best way to implement a 64 bit timer across tiles Topic is solved

If you have a simple question and just want an answer.
rob
Newbie
Posts: 1
Joined: Thu Oct 23, 2014 3:52 pm

Best way to implement a 64 bit timer across tiles

Post by rob »

I was wondering what the best way to implement a 64 bit timer with microsecond accuracy which is available across multiple tiles.

Since I'm using a slicekit-U16 I tried to access the real-time counter but for some reason the code just hung on the read_periph_32 call.

I thought about updating a variable based on the 32 bit timer and detecting when it wraps but this seems a bit messy.

Does any one have any other ideas?

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

Post by infiniteimprobability »

Your idea about using the U series timer is a good one - If your code is getting stuck on the periph write, then it's a channel issue - blocking because the other end is not receiving. You can check you code against the code examples here:

https://github.com/xcore/sc_a_series_support

That provides access to the timer in the sleep functions.

You can of course run a time on either tile, and have it queryable from the other. You can include overflow detection (triggered via an event) that will increment a variable, which gets you past the 40 odd second rollover of a 32b time at 100MHz. However, you will need a core that is ready listening to a channel end (or interface call) to retrun the timer value. Effectively a time server. This can be combined with other stuff in a select statement, or using combinable tasks.

Either sounds good..

 

 

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

Post by infiniteimprobability »

Here's a working example, built using the SLICEKIT-U16 target:


#include <stdio.h>
#include <platform.h>
#include <xs1_su.h>

int main(void){
unsigned int time_now[2];

read_periph_32(usb_tile, XS1_SU_PER_RTC_CHANEND_NUM, XS1_SU_PER_RTC_LWR_32BIT_NUM, 2, time_now);
printf("time_now[1]=%d, time_now[0]=%d\n", time_now[1], time_now[0]);
return 0;
}

Engineer at XMOS