195
If switching of the pin function generates a false input capture edge matching the edge selected by
the input capture interrupt edge select bit (IIEGS), the interrupt request flag will be set to 1,
making it necessary to clear this flag to 0 before using the interrupt function. Figure 9.13 shows
the procedure for modifying port mode register settings and clearing the interrupt request flag. The
first step is to mask interrupts before modifying the port mode register. After modifying the port
mode register setting, wait long enough for an input capture edge to be recognized (at least two
system clocks when noise canceling is disabled; at least five sampling clocks when noise
canceling is enabled), then clear the interrupt request flag to 0 (assuming it has been set to 1). An
alternative procedure is to avoid having the interrupt request flag set when the pin function is
switched, either by controlling the level of the input capture pin so that it does not satisfy the
conditions in tables 9.12 and 9.13, or by setting the IIEGS bit of TMG to select the edge opposite
to the falsely generated edge.
Set I bit to 1 in CCR
Clear I bit to 0 in CCR
Modify port mode register
Wait for TMIG to be recognized
Clear interrupt request flag to 0
Disable interrupts (or disable by clearing interrupt
enable bit in interrupt enable register 2)
Modify port mode register setting, wait for input
capture edge to be recognized (at least two
system clocks when noise canceling is disabled;
at least five sampling clocks when noise canceling
is enabled), then clear interrupt request flag to 0
Enable interrupts
Figure 9.13 Procedure for Modifying Port Mode Register and Clearing Interrupt
Request Flag