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 support@ccsinfo.com

Determining square-wave frequency input into pic
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alextee89



Joined: 01 Apr 2011
Posts: 2

View user's profile Send private message

PostPosted: Sat Apr 02, 2011 12:03 pm     Reply with quote

For 16f877a, if I don't want pass through ADC and how is the code? input connect to ccp1?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 02, 2011 12:10 pm     Reply with quote

None of the tachometer code that I posted uses the ADC. It all uses the CCP.

Read all the tachometer threads on this forum. They discuss every
detail of how to do it, and all the problems that need to be solved.

And don't post a comment at the end of every tachometer thread.
Just read them all.
dpechman



Joined: 04 Dec 2007
Posts: 43

View user's profile Send private message Visit poster's website

PostPosted: Thu Nov 03, 2011 6:15 pm     Reply with quote

I am thinking a way to trigger CCP by external interrupt or make similar to CCP technique to measure a taco signal from 100 to 1500Hz using rb0.

My first approach was not so precise and I have defined in my board the pin rb0 to measure the frequency.

I did it run partially using a timer + int_ext to read the accumulated between 2 rises to a variable and reset the counter, but using CCP pins looks for me now a much light weight and better option.

Am I wrong? any suggestion?
hisham.i



Joined: 22 Aug 2010
Posts: 43

View user's profile Send private message

PostPosted: Sat Aug 11, 2012 4:33 am     Reply with quote

Hello,

I know that this is an old post but i have a question concerning the ccp interrupt routine.
Code:
// value by code in main().
#int_ccp1
void ccp1_isr(void)
{
int16 current_ccp;
static int16 old_ccp = 0;

// Read the 16-bit hardware CCP1 register
current_ccp = CCP_1;  // From 16F877.H file

// Calculate the time interval between the
// previous rising edge of the input waveform
// and the current rising edge.  Put the result
// in a global variable, which can be read by
// code in main().
isr_ccp_delta = current_ccp - old_ccp;

// Save the current ccp value for the next pass.
old_ccp = current_ccp;
}


In second line you defined old_ccp=0;
so in each time you access the interrupt the variable old_ccp =0;
so each time you calculate isr_ccp_delta you are subtracting the new value from zero.

Please explain what i am missing.

Regards
hisham.i



Joined: 22 Aug 2010
Posts: 43

View user's profile Send private message

PostPosted: Sat Aug 11, 2012 4:42 am     Reply with quote

Sorry for my post i didn't recognize that this question was asked in the second page of the post.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
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