This is usually implemented in conjunction with a binary input line. A hardware counter counts the number of transitions (high to low or low to high, usually this is programmable) at a particular pin.
This may seem fairly useless because the same functionality can be done by software sampling. However, when this is done by hardware (of an MCU), it is very fast, accurate and does not tax the main processor.
Most counters can be set up so that when the counter reaches a certain specified number, it “interrupts” the processor to report the event.
Applications: