AnsweredAssumed Answered

accumulator mac instruction

Question asked by rofe on Nov 27, 2014
Latest reply on Nov 28, 2014 by rofe

Hello,

 

I have following problem:

 

I would like to make use of 40 bit accumulator and MAC units in BF592.

So I´ve written following function:

 

/* guaranteed to accumulate in 40 bits */

fract32 macPwr(fract16 a[], fract16 b[], short n)

{

  long long sum1 = 0;

  long long sum2 = 0;

  for (i = 0; i < n; ++i)

  {

  /* An += Rx.lh * Ry.lh (IS)   preserving the whole accumulator

  */

       sum1 = A_mac_IS(sum1, a[i], a[i]);

       sum2 = A_mac_IS(sum2, b[i], b[i]);

  }

  return (fract32)(sum1+sum2);

}

However, I need to enable optimization switch in the compiler to have expected performance.

The problem is that optimization switch is messing up with my SPI and I2C drivers so is it

possible to write that function in the way I don't need to enable that optimization?

 

Should I write it in assembly? If yes are they some examples?

Why optimization switch in compiler causes SPI and I2C problems?

 

Best Regards,

Roman

Outcomes