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
Frequency meter with ECCP
Moderator: Benj
- cubitus54
- Flowcode v5 User
- Posts: 110
- Joined: Wed Jun 19, 2013 7:18 am
- Has thanked: 7 times
- Been thanked: 32 times
Re: Frequency meter with ECCP
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
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
Flowcode V6.1.2.0(11 05 2015)
- cubitus54
- Flowcode v5 User
- Posts: 110
- Joined: Wed Jun 19, 2013 7:18 am
- Has thanked: 7 times
- Been thanked: 32 times
Re: Frequency meter with ECCP
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;
Flowcode V6.1.2.0(11 05 2015)