Timers....

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
User avatar
In_Control001
Member++
Posts: 20
Joined: Thu Mar 04, 2010 7:27 pm

Timers....

Post by In_Control001 »

Hi guys,

I use this code to try the hardware Timers:

Code: Select all

#include <xs1.h>
#define DELAY 50000000

out port p = XS1_PORT_1A;

int main(void)
{
	unsigned state = 1, time;
	timer t;
	t :> time;
	while(1)
	{
		p <: state;
		time += DELAY;
		t when timerafter(time) :> void;
		state = !state;
	}
}
Something is wrong, caus it endless waits on the timer to become equal.

regards,
Jo


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

Post by Andy »

Can you give a little more information on the problem you're having? Which board are you running it on/ does it work in the simulator etc?
User avatar
In_Control001
Member++
Posts: 20
Joined: Thu Mar 04, 2010 7:27 pm

Post by In_Control001 »

Andy wrote:Which board are you running it on/ does it work in the simulator etc?

->Simulator mode.
->I c in the simulator that it keeps hanging on the timerafter().
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

Each input will pause for half a second (200 million processor cycles). On my machine it takes about 4 seconds to simulate a million processor cycles and so it would take 13 minutes to simulate this number of processor cycles. If you a simulating a multi-core system it will take even longer.

Are you sure it is hanging and not just taking a long time.
User avatar
In_Control001
Member++
Posts: 20
Joined: Thu Mar 04, 2010 7:27 pm

Post by In_Control001 »

I have 2 cores running at 2.3GHz.

It take 4 secs to run 1000.000 cycles?


Amazing....

When I take a timeafter from 1000 it goes very fast.

When I take 10.000 it hangs?

Its only a factor of 10.
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am
Contact:

Post by paul »

Remember the simulator is simulating the architecture quite accurately - so its quite heavyweight. If you want a fast instruction set simulation just run xsim with the -i flag.
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Post Reply