XC886/888CLM
Multiplication/Division Unit
User’s Manual
10-4
V1.3, 2010-02
MDU, V2.1
10.1.4
Busy Flag
A busy flag is provided to indicate the MDU is still performing a calculation. The flag
MDUSTAT.BSY is set at the start of a calculation and cleared after the calculation is
completed at the end of phase two. It is also cleared when the error flag is set.
If a second operation needs to be executed, the status of the busy flag will be polled first
and only when it is not set, can the start bit be written and the second operation begin.
Any unauthorized write to the start bit while the busy flag is still set will be ignored.
10.1.5
Error Detection
The error flag MDUSTAT.IERR is provided to indicate that an error has occurred while
performing a calculation. The flag is set by hardware when one of these occurs:
•
Division by zero
•
Writing of reserved opcodes to MDUCON register
The setting of the error flag causes the current operation to be aborted and triggers an
interrupt (see
below). A division by zero error does not set the error flag
immediately but rather, at the end of calculation phase for a division operation. An
opcode error is detected upon setting MDUCON.START to 1. Errors due to division by
zero lead to the loading of a saturated value into the MRx registers.
Note: The accuracy of any result obtained when the error flag is set is not guaranteed
by MDU and hence the result should not be used.
10.2
Interrupt Generation
The interrupt structure of the MDU is shown in
. There are two possible
interrupt events in the MDU, and each event sets one of the two interrupt flags. The
interrupt flags is reset by software by writing 0 to it.
At the end of phase two, the interrupt flag MDUSTAT.IRDY is set by hardware to indicate
the successful completion of a calculation. The results can then be obtained from the
MRx registers. The interrupt line INT_O0 is mapped directly to this interrupt source.
An interrupt can also be triggered when an error occurs during calculation. This is
indicated by the setting of the interrupt flag MDUSTAT.IERR. In the event of a division
by zero error, MDUSTAT.IERR is set only at the end of the calculation phase. Once the
MDUSTAT.IERR is set, any ongoing calculation will be aborted. For a division by zero
error, a saturated value is then loaded into the MRx registers. The bit MDUCON.IR
determines the interrupt line to be mapped to this interrupt source.
An interrupt is only generated when interrupt enable bit MDUCON.IE is 1 and the
corresponding interrupt event occurs. An interrupt request signal is always asserted
positively for 2 clocks.
*