
MPY32 Operation
14.2.7.1 Save and Restore
If the multiplier is used in interrupt service routines, its state can be saved and restored using the
MPY32CTL0 register. The following code example shows how the complete multiplier status can be saved
and restored to allow interruptible multiplications together with the usage of the multiplier in interrupt
service routines. Because the state of the MPYSAT and MPYFRAC bits are unknown, they should be
cleared before the registers are saved as shown in the code example.
; Interrupt service routine using multiplier
MPY_USING_ISR
PUSH
&MPY32CTL0
; Save multiplier mode, etc.
BIC
#MPYFRAC,&MPY32CTL0
; Clear MPYFRAC
PUSH
&RES3
; Save result 3
PUSH
&RES2
; Save result 2
PUSH
&RES1
; Save result 1
PUSH
&RES0
; Save result 0
PUSH
&MPY32H
; Save operand 1, high word
PUSH
&MPY32L
; Save operand 1, low word
PUSH
&OP2H
; Save operand 2, high word
PUSH
&OP2L
; Save operand 2, low word
;
...
; Main part of ISR
; Using standard MPY routines
;
POP
&OP2L
; Restore operand 2, low word
POP
&OP2H
; Restore operand 2, high word
; Starts dummy multiplication but
; result is overwritten by
; following restore operations:
POP
&MPY32L
; Restore operand 1, low word
POP
&MPY32H
; Restore operand 1, high word
POP
&RES0
; Restore result 0
POP
&RES1
; Restore result 1
POP
&RES2
; Restore result 2
POP
&RES3
; Restore result 3
POP
&MPY32CTL0
; Restore multiplier mode, etc.
reti
; End of interrupt service routine
14.2.8 Using DMA
In devices with a DMA controller, the multiplier can trigger a transfer when the complete result is available.
The DMA controller needs to start reading the result with MPY32RES0 successively up to MPY32RES3.
Not all registers need to be read. The trigger timing is such that the DMA controller starts reading
MPY32RES0 when its ready, and that the MPY32RES3 can be read exactly in the clock cycle when it is
available to allow fastest access via DMA. The signal into the DMA controller is 'Multiplier ready' (see the
DMA Controller chapter for details).
423
SLAU272C – May 2011 – Revised November 2013
32-Bit Hardware Multiplier (MPY32)
Copyright © 2011–2013, Texas Instruments Incorporated