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
10uS Timer
Moderator: Benj
-
- Posts: 234
- Joined: Thu May 31, 2007 2:18 pm
- Has thanked: 7 times
- Been thanked: 12 times
- Contact:
-
- 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
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
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
Last edited by medelec35 on Sun Feb 06, 2011 10:02 pm, edited 1 time in total.
Martin
-
- Posts: 234
- Joined: Thu May 31, 2007 2:18 pm
- Has thanked: 7 times
- Been thanked: 12 times
- Contact:
Re: 10uS Timer
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
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
-
- 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
If you let me know target device, osc type. internal external etc and speed. I will create one for you to work with.
Martin
-
- Posts: 234
- Joined: Thu May 31, 2007 2:18 pm
- Has thanked: 7 times
- Been thanked: 12 times
- Contact:
-
- 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
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
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
-
- Posts: 27
- Joined: Sat Aug 01, 2009 3:15 pm
- Has thanked: 2 times
- Been thanked: 10 times
- Contact:
Re: 10uS Timer
Hi medelec35,
I have not seen ! used before (Output = !Output), can you explain it's function?
Thanks,
ben
I have not seen ! used before (Output = !Output), can you explain it's function?
Thanks,
ben
-
- 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
Hiya BenHarry Tuttle wrote: (Output = !Output), can you explain it's function?
Thanks,
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