Since it's not a problem for the PIC chip, or for PBP ...
Will there be a Second Attempt?
I'd hate to interfere with the learning process.
But I would suggest using the Timer0 input (T0CKI) for the frequency to be measured.
The Timer0 prescaler has a minimum period of 20nS, which means it can take up to 50Mhz.
Timer1 (T1CKI) can only take up to 1Mhz with a 4Mhz OSC, or 5Mhz with a 20Mhz OSC.
Any frequency measurement requires an accurate "Time Base".
And the easiest way to get that is to use a 32768 Hz crystal on the Timer1 oscillator.
This way, Timer1 generates the 1 sec window, and Timer0 (and it's overflows) counts the frequency.
It is a little tricky to read the Timer0 prescaler to get the lowest byte of the count though.
The prescaler should be 1:256 (the default).
Oh, and the PICs oscillator should be as fast as possible, so that the program can respond to the hardware flags, which have to be polled.
The fastest oscillator for the 16F877A is 20 Mhz.
A simulation works good up to 600Kz. Reading the exact Hz. (actual results will depend on the 32768 crystal tolerance)
A real chip should go much higher, but the SIM crashes with the higher frequency.
Sometimes you just need to know it can be done ... so you can figure it out on your own.
Bookmarks