hi
i am using flowcode 5 free version and 16f627a with 20 MHz crystal.....i want use TMR2 to make 1Mhz interrupt per second...i couldn't make it....it give me about 45000 interrupt per second...why?
help..TMR2 to make 1Mhz interrupt per second
Moderator: Benj
- 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: help..TMR2 to make 1Mhz interrupt per second
Hello,
If you set the prescaler and postscaler to 1:1 and the rollover to 5 then the maths says you should get a interrupt frequency of 1MHz.
However with only 5 instructions between each interrupt it would be my guess that you cannot do anything useful in 5 instructions.
Also there may be at least a couple of instructions overhead in firing the interrupt so my guess is a 20MHz PIC cannot generate a 1MHz interrupt.
An AVR might have more chance as you don't have the inherent divide by 4 on the clock speed as you do with 8-bit PICs.
Do you mind me asking what you intend to use the 1 MHz interrupt for? If it's for driving output pins then you might struggle as I don't think the I/O will run that fast even on an AVR, I could be wrong.
If you set the prescaler and postscaler to 1:1 and the rollover to 5 then the maths says you should get a interrupt frequency of 1MHz.
However with only 5 instructions between each interrupt it would be my guess that you cannot do anything useful in 5 instructions.
Also there may be at least a couple of instructions overhead in firing the interrupt so my guess is a 20MHz PIC cannot generate a 1MHz interrupt.
An AVR might have more chance as you don't have the inherent divide by 4 on the clock speed as you do with 8-bit PICs.
Do you mind me asking what you intend to use the 1 MHz interrupt for? If it's for driving output pins then you might struggle as I don't think the I/O will run that fast even on an AVR, I could be wrong.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: help..TMR2 to make 1Mhz interrupt per second
hi Benj
i want Measure pulse period..any suggestion?
i want Measure pulse period..any suggestion?
-
- Valued Contributor
- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
- Contact:
Re: help..TMR2 to make 1Mhz interrupt per second
As you are not sharing a tip or trick I have moved this message to the appropriate forum. Please do not use the 'Tips and Tricks' forum for requests for help.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis
- 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: help..TMR2 to make 1Mhz interrupt per second
Hello,
What's the min / max frequency of the pulse you want to monitor and what resolution do you need?
What's the min / max frequency of the pulse you want to monitor and what resolution do you need?
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: help..TMR2 to make 1Mhz interrupt per second
the pulse length 500ms...i want highest resolution..1us or ns