I'm not going to look in detail at it but, instead, refer you to this page: Gammon Forum : Electronics : Microprocessors : Timers and counters
(a) it has a ready made frequency meter using input capture on one edge only, which is exactly what you want.
(b) it appears to have the same parentage as the @johnwasser version.
However, if you are lucky, John will help you out.