multiple interrupts -- determining frequency of signal
Posted: Sun Apr 10, 2005 9:36 pm
Basically, I'm curious what the best way to determine the frequency of a singnal is. I have the input hooked up to the rb0/int pin on the PIC. I enable interrupts and have an int_ext interrupt set up.
The way that I'm thinking of coding this is to have the interrupt subroutine jump into a function that will start a timer and wait for another interrupt to come. Once this second interrupt comes it will check to see the value of the timer and calculate the period of time that has elapsed.
What I'm curious about it if there's a way to receive multiple interrupts while in the ISR. Also with a 20MHz clock and a ~6KHz signal will there be too much overhead of hopping in and out of functions that it will mess up my value?
Any suggestions or examples would be greatly appreciated. Thanks in advance!
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
Posted: Sun Apr 10, 2005 9:43 pm
If your PIC has a CCP module, then look there. Read the section in the datasheet on it. You can configure it to capture a timer value. Knowing the rate of the timer will allow you to calculate the freq.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum