ARM timer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

ARM timer

Post 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 :roll:

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ARM timer

Post 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?

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ARM timer

Post 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.

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post by wayne millard »

Thanks Benj i will give it a go tonight.

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post by wayne millard »

Hi Benj,

What have i done wrong i still have the same problem.

Thanks,
Wayne
Attachments
Test2.fcf_arm
(4.5 KiB) Downloaded 292 times

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ARM timer

Post 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.

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post by wayne millard »

Thanks i will wait for reply from Sean.
And thanks for all the help

Wayne

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post 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 :D

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post 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

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: ARM timer

Post 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.

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post 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 :?

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times

Re: ARM timer

Post 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 :oops:

Post Reply