frequency counter using pic16f877a
There are two different common methods to measure frequency with this PIC.  Which one is appropriate depends on things you haven't told us, like the minimum and maximum frequency.

The conceptually simple way is to do a frequency counter.  Hardware can assist here in that you can have a external signal increment timer 0 or timer 1.  Then the firmware reads the timer at known intervals, and the rest is simple math.  Note that you do NOT want to reset the timer after each read.  Simply do a unsigned integer subtract of the new reading minus the previous and you get the counts in the last interval.

You have to keep timer overflow in mind.  Timer 0 is 8 bits and timer 1 16 bits.  If using timer 0, for example, you have to be sure that the sampling period is short enough so that there are less than 256 cycles per period at the highest input frequency.  With timer 1 you get a lot more room since it's 16 bits wide.  You can therefore allow up to 65535 cycles per sampling period.

The other way to measure frequency is to actually measure the period of individual cycles or groups of cycles.  This is best done by using one of the CCP modules in capture mode.  Timer 1 is set up as a free running timer, and the CCP module takes a snapshot of it every 1, 4, or 16 periods of the external signal.  In the CCP interrupt, you subtract the new capture reading minus the previous to get the time duration of the external period (or 4 or 16 periods), and the rest is math.

The CCP capture method is usually more accurate and responsive, but more tricky to implement and to deal with all the corner cases.  With this method you have to worry about timer overflow for low input frequencies, not high.  I usually deal with this by grabbing the timer value periodically faster than it can wrap, and effectively extending the timer to a arbitrary number of bits in firmware.