46.4.6 Position Comparator
The QEIxCMPL and QEIxICC registers and the associated comparator provide the ability to compare the contents of the Position Counter (POSxCNT) register to a specified value. The comparator provides two outputs: equality detect, and less than or greater than detect. The comparator equality output can be enabled to generate interrupts via the PCLEQIEN bit (QEIxSTAT<10>). The less than or equal, or greater than or equal output can be output on a device pin. The selection is made by setting the OUTFNC<1:0> bits (QEIxIOC<10:9>). The comparator output can be used to detect an illegal move operation by an end user and the comparator output can be connected to appropriate external circuitry to prevent the illegal move.
Sometimes, the potential for costly damage to a part, or a machine due to an operator, programming,or a machine failure is too much to accept. The QEIxCMPL and QEIxICC registers can be configured to define a bounds of travel beyond which a Fault is generated. The values in these registers are continually compared to the position counter. The comparator output can be directed to a device pin. This Fault detected signal can be used to shut down the machine operation to prevent damage or injury.
The comparator can also be used to reset the position counter when a match is detected. Figure 46-8, on the previous page, illustrates the index reset position counter operation.
