High frequency interrupt (16F15323)

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Lord Grezington
Flowcode V4 User
Posts: 288
Joined: Wed Nov 02, 2011 11:15 pm
Has thanked: 29 times
Been thanked: 30 times
Contact:

High frequency interrupt (16F15323)

Post by Lord Grezington »

Hey everyone

Looking at a new project, thinking about using a IOC pin to measure frequencies around 100Khz. Not really done thes high frequencies before, so the first things that come to mind are?

What clock frequency will I need? is it possible to do it with a 32Mhz interlal oscillator?
The program itself wont actually be performing many other tasks other than checking a couple other inputs and setting some PWM outputs.

Was thinking about using the IOC and a timer, but is tehre an easier way ? Thinking along the lines of something like Using Timer1 and measuring the transition on T0CK1 or something? How would I do this and is using hte IOC not easier? which one will be more accurate? (measuring square wave duty cycle on the input).

Another thing I may want to look at is how do I prioritise the various interuppts?

And finally, is it possible to use the IOC port twice? meaning can I set the IOC to look at 2 pins and run one macro, then set two other pins to run a different macro?

Thanks

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: High frequency interrupt (16F15323)

Post by QMESAR »

HI
Looking at a new project, thinking about using a IOC pin to measure frequencies around 100Khz. Not really done thes high frequencies before, so the first things that come to mind are?
These things are normally done by using the Capture Compare module of the PIC as it allows you to read the Capture registers which is in effect a Timer value
P1.jpg
P1.jpg (104.81 KiB) Viewed 2398 times

I would not use any Clock less that 32Mhz and my reason is your 100Khz signal has a time of 10uSec a PIC 16 running at 32Mhz has Tcy of 125nSec
so the time you have between catures is 10/125 = 80 cycles, not much to calculate the frequency and other stuff from the captured values.

Note that if you do not need to capture each transition of the signal you can set the Capture module to capture every 4 or 16th pulse allowing you to get more time between the captures for the other things you need in code
P2.jpg
P2.jpg (18.86 KiB) Viewed 2398 times
But I am sure you can capture the signal and the chip has 2 CCP modules you can detect 2 signals at once .
Check out the datasheet section Capture and compare and you will see you can achieve what you need to do with this chip with just using the chip correctly.

Post Reply