ATmega328P use counters

Hi
What function software can I use to count the pulses from an incremental transducer.

I would like to use the 16-bit counter and its capture function ,to read the value it has reached at a certain point, while it continues to count.

How can I program the counter to count on the rising or falling front of the input pulse.

Thanks !

Good tutorial on ATmega328 timers. Scroll down to input capture unit.

Thanks for help !