Page 1 of 1
ARM timer
Posted: Wed May 04, 2011 9:07 pm
by wayne millard
Hi Team,
i need to generate times of upto 30ms with an accuracy of 1us.
i can send timer1 overflow register decimal numbers the max i can
send is 65535 because i think that the register is a 16bit so how
can i use a 16bit which i think there is in the arm chip or is there
another way or am i doing something wrong
Thanks,
Wayne

Re: ARM timer
Posted: Thu May 05, 2011 9:49 am
by Benj
Hello Wayne,
Registers on the ARM device are 32-bit. How come you created a new topic? Was the last solution I suggested to you any good?
Re: ARM timer
Posted: Thu May 05, 2011 11:46 am
by wayne millard
Hi Benj
Sorry for the new topic.
Yes what you suggested works well but if i send a number grater than 64800 which gave me 2.7ms.
so fast.
This was what i was doing. if i wont a time of 30ms i do as then that is 30000 * 24 sent to the overflow register.
Thanks
Wayne
Re: ARM timer
Posted: Thu May 05, 2011 2:39 pm
by Benj
Hi Wayne,
It might be better to do the caluclation in C as doing the multiply in Flowcode using an INT variable will give you an upper limit of 65536.
Here is the C code I would use.
Code: Select all
unsigned long multiplier = FCV_MULTIPLIER;
AT91C_BASE_TC1->TC_RC = (unsigned long) 24 * multiplier ;
where the "multiplier" variable is a Flowcode INT variable containing your microsecond count value.
Re: ARM timer
Posted: Thu May 05, 2011 3:55 pm
by wayne millard
Thanks Benj i will give it a go tonight.
Re: ARM timer
Posted: Thu May 05, 2011 10:14 pm
by wayne millard
Hi Benj,
What have i done wrong i still have the same problem.
Thanks,
Wayne
Re: ARM timer
Posted: Fri May 06, 2011 12:13 pm
by wayne millard
Hi Benj,
Can you see why i still have the problem that i cant get times grater than 2.7ms.
Thanks
Wayne
Re: ARM timer
Posted: Fri May 06, 2011 12:33 pm
by Benj
Hello Wayne,
I have asked Sean to have a look and see if he can figure out what is going wrong as he knows more about the working of the ARM devices.
One thing you could do is to make up the delay by passing the interrupt length to the rollover register as you are currently doing and then if the delay is longer then 2.7ms then you could then enable a second interrupt for the remaining period of time. Chaining these together would allow you to create a delay of any length with 1us granularity.
Re: ARM timer
Posted: Fri May 06, 2011 4:00 pm
by wayne millard
Thanks i will wait for reply from Sean.
And thanks for all the help
Wayne
Re: ARM timer
Posted: Tue May 10, 2011 8:39 am
by wayne millard
Hi Team,
Im just wondering if Sean has had a look to see what the problem with writing large numbers to the overflow register.
Thanks,
Wayne

Re: ARM timer
Posted: Wed May 11, 2011 2:19 pm
by wayne millard
Hi Team,
I have just looked at the data sheet for the AT91SAM7S128 and the timers are 16bit so i guess that is the problem.
So there seems to be a way of connecting two timers together would that solve the problem.
and can you help with this if that will solve problem?
Thanks
Wayne
Re: ARM timer
Posted: Wed May 11, 2011 3:40 pm
by Benj
Hi Wayne,
Aha that would do it.
Ok what I would do then is to create say a timer value and a Flowcode byte repeat variable to hold the flag.
Code: Select all
unsigned long multiplier = FCV_MULTIPLIER;
FCV_REPEAT = 0;
multiplier = (unsigned long) 24 * multiplier ;
if ((long) multiplier < 65536)
{
AT91C_BASE_TC1->TC_RC = multiplier;
}
else
{
AT91C_BASE_TC1->TC_RC = (long )multiplier - 65535;
FCV_REPEAT = 1;
}
In your flowcode program when the interrupt occurs see if the repeat variable is set. If it is then start the interrupt off again this time with a count of 65535.
Re: ARM timer
Posted: Wed May 11, 2011 10:00 pm
by wayne millard
Hi Benj,
So i check the result flag and if = 1. do i set multiplier to 65535.
will this still give accurate times + - 1us of desired time.
Thanks
wayne

Re: ARM timer
Posted: Mon May 16, 2011 3:17 pm
by wayne millard
Hi Team,
Sorry to be a pain in the neck.
Still cant get a programable 1uS timer grater than 2.7ms. need upto 30ms
i need to have two output's a start and a stop on different I/O pins.
The start would be generated on the interrupt and the Stop off some
flag??
Thanks,
Wayne
