Hi
I found this issue, which is probably a misunderstanding of the family manual for MSP430FR2/FR4 family.
But, even after a lot of digging cannot seem to find out what is wrong.
It says in section 16.2.2 of the family manual under the MPY32 chapter that the carry bit (MPYC) in a MACS operation reflects the carry of the accumulation.
But, from my small test program I somehow can not manage to see that.
I do first a simple signed MPYS operation of -6 and 5 that gives a result of -30 as expected.
And for MPYS operations the carry bit should be set to the sign of the result, which it is. MPYC is 1 (set) in this case.
However, when following up with a MACS operation of -4 by -5, the multiplied result that is 20 should be added
to the previous result (-30) to give -10. A result that I get. But, to my surprise the carry bit (MPYC) is set in MPY32CTL0.
WHY?
Since I work with a 16x16 multiplication, the accumulation of the previous result with the new multiplication should be done in 32 bits.
The previous result is (-30, 0xFFFF FFE2) added to the the new multiplication (+20, 0x14) is indeed -10 (0xFFFF FFF6).
But, this sum does NOT overflow 32 bit (FFFF FFE2 + 0000 00014 = FFFF FFF6), so no carry should be set?
What am I mis-understanding here?
Note 1: I can indeed reproduce same effect when using full 32x32 bit multiplications.
Note 2: All my examples produce expected RESx registers and SUMEXT register, the ONLY issue is with
the MPYC bit in MACS operation. All other multiply operation types give a MPYC bit that matches the family manual description.
Here is the example program that I run and that gives at the last line (status = MPY32CTL0) a MPYC bit set to 1, when I expect 0!
// START SAMPLE CODE:
int main(void)
{
volatile unsigned int i, j, status;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
// some test multiplications
MPYS = 0xFFFA; // -6
OP2 = 0x5; // +5 => (-6)*(+5) = -30
__no_operation();
i = RESLO;
j = RESHI;
status = MPY32CTL0;
__no_operation();
MACS = 0xFFFC; // -4
OP2 = 0xFFFB; // -5 => (-4)*(-5) = +20 Total accumulation => -30 + 20 = -10
__no_operation();
i = RESLO;
j = RESHI;
status = MPY32CTL0;
}
// END SAMPLE CODE
Appreciate if someone can point out the problem here.
Sincerely Brown Bear
