To detect such a condition, a stall detection feature is also implemented. By using the Hardware Limit Timer (HLT) of the TMR2 peripheral, the absence of a Hall signal within a period of time, can be detected. It is set to operate in rollover Pulse mode. In this mode, an input signal is allowed to clear the TMR2 register every time a falling edge transition is detected. When the pulse is absent or has a long periodic time, TMR2 will continuously increment until it reaches its maximum value, setting its Overflow bit. HLT will trigger an interrupt that disables all CWG peripherals, stopping the motor. In this application, the Hall B signal, which is connected to the RC6 input, is used as the reference signal. The signal provided by the Hall sensor has an approximate period of 5 ms in a normal setup. If the timer counter matches the PR value, the interrupt flag will be set as shown in Figure 5-1. The PR value that will be set on TMR2 should be larger than the period of the Hall sensor signal, in order to identify the stall condition of the motor. To calculate TMR2 PR register values, use Equation 5-2.