View previous topic :: View next topic |
Author |
Message |
alextee89
Joined: 01 Apr 2011 Posts: 2
|
|
Posted: Sat Apr 02, 2011 12:03 pm |
|
|
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
|
|
Posted: Sat Apr 02, 2011 12:10 pm |
|
|
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
|
|
Posted: Thu Nov 03, 2011 6:15 pm |
|
|
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
|
|
Posted: Sat Aug 11, 2012 4:33 am |
|
|
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
|
|
Posted: Sat Aug 11, 2012 4:42 am |
|
|
Sorry for my post i didn't recognize that this question was asked in the second page of the post. |
|
|
|