19.6.3 Using the Input Capture Unit
The main challenge when using the input capture unit is to assign enough processor capacity for handling the incoming events. The time between two events is critical. If the processor has not read the captured value in the ICRn before the next event occurs, the ICRn will be overwritten with a new value. In this case the result of the capture will be incorrect.
When using the input capture interrupt, the ICRn should be read as early in the interrupt handler routine as possible. Even though the input capture interrupt has relatively high priority, the maximum interrupt response time is dependent on the maximum number of clock cycles it takes to handle any of the other interrupt requests.
Using the input capture unit in any mode of operation when the TOP value (resolution) is actively changed during operation, is not recommended.
Measurement of an external signal’s duty cycle requires that the trigger edge is changed after each capture. Changing the edge sensing must be done as early as possible after the ICRn has been read. After a change of the edge, the ICF must be cleared by software (writing a logical one to the I/O bit location). For measuring frequency only, the clearing of the ICF is not required (if an interrupt handler is used).