CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Trying to make a frequency counter using CCP1

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
sigmunt



Joined: 25 Feb 2010
Posts: 2

View user's profile Send private message

Trying to make a frequency counter using CCP1
PostPosted: Thu Feb 25, 2010 8:53 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 25, 2010 12:02 pm     Reply with quote

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:

Code:
setup_ccp1()

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

View user's profile Send private message

PostPosted: Thu Feb 25, 2010 7:36 pm     Reply with quote

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 ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group