1.2.7 Overflow and Saturation Handling

The DSP Library performs most computations using 9.63 saturation but must store the output of the function in 1.31 format. If the accumulator in use saturates during the course of operation, the corresponding saturation bit (SA or SB) in the STATUS register will be set. This bit will stay set until it is cleared. This allows the inspection of SA or SB after the function executes and to determine if action should be taken to scale the input data to the function.

Similarly, if a computation performed with the accumulator results in an overflow, the corresponding overflow bit (OA or OB) in the STATUS register will be set. Unlike the SA and SB status bits, OA and OB will not stay set until they are cleared. These bits are updated each time an operation is executed by using the accumulator. If exceeding this specified range marks an important event, it is recommended to enable the Accumulator Overflow Trap via the OVATE, OVBTE and COVTE bits in the INTCON4 register. This will have the effect of generating an Arithmetic Math Error Trap as soon as the Overflow condition occurs to then take the required action.