Page 1 of 1

High frequency interrupt (16F15323)

Posted: Sat Jan 26, 2019 7:06 pm
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

Re: High frequency interrupt (16F15323)

Posted: Sun Jan 27, 2019 7:59 am
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 2426 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 2426 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.