10uS 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
Contact:

10uS Timer

Post by wayne millard »

Hi to all

How can i make a timer interrupt run at a 10us rate so that i can generate times to the nearest 10us.

Thanks,
Wayne :P

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 10uS Timer

Post by medelec35 »

Hiya Wayne
10uS = 1/ 10x10-6 =100KHz
So depending on osc speed, you can use timer 0 or If not using PWM, timer 2 to generate interrupt at that speed (time)
You have a choice of selecting a slightly shorter int time then using format:
count = count + 1
count < a_number
then count = 0: Flag = 1 etc
Or you select a slower int frequency and add tmr0l += a_number; (or tmr0 depending on your target device).

If you want to post a flowchart that is set up for your target chip and osc speed + type of osc.
Then I will see if I can add the 10uS int macro.
10us is very quick, wont leave much time for anything else :P
Last edited by medelec35 on Sun Feb 06, 2011 10:02 pm, edited 1 time in total.
Martin

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

Re: 10uS Timer

Post by wayne millard »

Thanks medelec35,

I have not started the project yet just need to get the timer working first then start on the project.
any help would be very grateful.

Wayne

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 10uS Timer

Post by medelec35 »

If you let me know target device, osc type. internal external etc and speed. I will create one for you to work with.
Martin

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

Re: 10uS Timer

Post by wayne millard »

medelec35,

I will use a 18F4520 and some thing like a 10Mhz clock.

Thanks
wayne :P

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 10uS Timer

Post by medelec35 »

Here is a version with a 10uS interrupt
Note the higher the osc frequency the better.
So I have enabled osc PLL x 4
Now with a 10MHz osc, the chip will be running a 10x4 = 40MHz
Attachments
10uS INT.fcf
(4.5 KiB) Downloaded 328 times
Martin

Harry Tuttle
Posts: 27
Joined: Sat Aug 01, 2009 3:15 pm
Has thanked: 2 times
Been thanked: 10 times
Contact:

Re: 10uS Timer

Post by Harry Tuttle »

Hi medelec35,

I have not seen ! used before (Output = !Output), can you explain it's function?

Thanks,
ben

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: 10uS Timer

Post by medelec35 »

Harry Tuttle wrote: (Output = !Output), can you explain it's function?

Thanks,
ben
Hiya Ben

I have used '=!' as a bitwise 'not equal to'.
So what it does is toggles the value of Output.
So If Output = 0 then after Output = !Output
Output will change to 1

If Output = 1 then after Output = !Output
Output will change to 0
etc.

So in this case was toggling port A0 every time interrupt was accessed.

I find it an easier method to learn than
Toggle = (Toggle XOR 0b11111111) AND 1

The 1 on the far right is the bit you want to toggle.
So if you want to toggle bit 3 you will need to use
Toggle = (Toggle XOR 0b11111111) AND 4
etc.
Martin

Post Reply