Page 1 of 1
Frequency meter with ECCP
Posted: Wed Apr 23, 2014 5:49 pm
by cubitus54
Hello,
Does someone would have an example of frequency meter using ECCP.
I want to measure the frequency of a light sensor TSL235 (1KHz - 1MHz)
thank you
Re: Frequency meter with ECCP
Posted: Tue Apr 29, 2014 6:45 pm
by cubitus54
Hello,
To test, I used a PIC 18F26K20
The frequency is given by a function generator.
To view the results, I send the program two words in SPI I view the oscilloscope.
My current problem is that the low word is good, for against the high word appears either 0 or 255
On the pictures you see, the frequency 56K (D2)
high value 0
low value 1E
Normally I should have 11E is 286 * 0.0625μs 17.8μs = 55.9 kHz
Why I can not get the high value?
thank you
Re: Frequency meter with ECCP
Posted: Wed Apr 30, 2014 9:42 am
by cubitus54
I found
Code: Select all
FCV_PERIODEL=ccpr1l;
FCV_PERIODEH=ccpr1h;
FCV_ANCIENL=FCV_PERIODEL;
FCV_ANCIENH=FCV_PERIODEH;
FCV_PERIODE=((FCV_PERIODEH<<8)|FCV_PERIODEL)-FCV_ANCIEN;
FCV_ANCIEN=(FCV_ANCIENH<<8)|FCV_ANCIENL;
FCV_MAJ=1;