View previous topic :: View next topic |
Author |
Message |
sigmunt
Joined: 25 Feb 2010 Posts: 2
|
Trying to make a frequency counter using CCP1 |
Posted: Thu Feb 25, 2010 8:53 am |
|
|
Hello ,
I'm trying to make a frequency counter using this technique:
Main routine to update the 7 Seg display.
Timer2 to make a timebase near 1 Second , and display the counter,
and CCP1 to capture the Input Signal and increasing the Counter.
I was expecting to only receive an interrupt when the CCP1 overflow 65536 , and just have to multiply the value to obtain the final frequency
But instead, the pic interrupts at each count on the CCP1 pin, using too much CPU ( after 30 000/sec pulses the PIC Cpu is at 100%).
I've not found anywhere how to add a prescaler in CCP1 with CCS.
Anyone can help ?
Thanks a lot ! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 25, 2010 12:02 pm |
|
|
Quote: |
I've not found anywhere how to add a prescaler in CCP1 with CCS. |
Download the CCS manual:
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf
Look in this section:
Look at the list of parameters that control the CAPTURE mode.
There are parameters in the list which allow you to set the CCP prescaler
for capture mode. Look for settings such as: CCP_CAPTURE_DIV_x
Also look in the .H file for your PIC, in the CCP section. It also lists
the parameters. Example of .h file:
Quote: | c:\program files\picc\devices\18f452.h |
|
|
|
sigmunt
Joined: 25 Feb 2010 Posts: 2
|
|
Posted: Thu Feb 25, 2010 7:36 pm |
|
|
Thanks for the Answer PCM !
I'm now able to display frequency 8 times more fast ;)
But I'm still wondering if it is possible to count frequency higher than the oscillator frequency ( up to 40-50mhz ) with a 1 Hz accuracy ? |
|
|
|