In interrupt routine,
On first rising edge I have reset the timer3 . and on next rising edge I have taken CCP2 register value. So this will be my timer counter(16 bit) between two rising edge.
From the above details we can calculate timer3 frequency = 625000 Hz.
Code:
#define FREQ_CONST 625000L
1) so Frequency of subjected waveform = (unsigned char)(FREQ_CONST / timer counter )
Is this above method is OK ? any betterment using CCP2 module only.?
2) When power goes off , the signal at micro ccp2 pin will be at low state. Supposing that just before power gets off micro has detected a rising edge and reset the timer3 .Now micro will not get a rising edge until power comes .So I can’t update frequency(let’s say in last calculation frequency was 49 Hz) .But I have to detect the frequency .
To solve this ……
I have created a 10ms time base using timer0.At every 10 ms I will increment a counter
Code:
Void f1_10ms(){
Zxcntr++;
}
I will reset that counter whenever there is rising edge found.In case of power goes off this counter will not reset .So I will check 5 such count i.e 50 ms and conclude that frequency is zero and reset that counter.
Is this method correct and reliable ? Could anybody suggest me for any better method ?
Regards,
Arup
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Tue Apr 08, 2008 11:12 pm
There are several threads on using the CCP to find the frequency.
Just search for:
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