mfr32Sqrt

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

mfr32Sqrt

414 Views
JhonatanIG
Contributor I

Morning everybody,

 

I need help with the square root function into MC56F8037EVM board, that is DSC of 16 bits. The specify question is: How can I do a mathematic operation (SQRT) using this bean "MRF1:smileyvery-happy:SP_Func_MFR"?

 

I tried to do it like shown below:

 

void main(void)
{
  Frac16 r;
  PE_low_level_init();

  for(;:smileywink:
  {
  r=mfr32Sqrt(81);    //I like to apply the square root to the decimal number 81. The answer would be 9
  Bt21_PutVal(r);      // This instruction only send the result by the port C (16 bits). I hope (0000 0000 0000 1001)
  }
}

 

Thanks a lot, and i hope your help

Labels (1)
0 Kudos
1 Reply

249 Views
ProcessorExpert
Senior Contributor III

Hello,

 

the DSP_Func_MFC Frac16 or Frac32  values. Even thought that they are technically integer, these values represent fractional range -1 <= x < 1. So if you put directly integer inside (e.g. 81) it is treated like a corresponding fractional number - so for 81 it you are actually caclulating sqrt(0.002471923828125)  [you can get the float this way : 81 * 1 / 0x8000. so you would  get something like 1629, which corresponds to the result 0.0497184456.

Please see the DSP_Func_MFR component help for detailson fractional number representation , I recomment to use the link "Programmers guide" from the component "General Info" page.

I suppose you would need to use different library.

 

best regards
Petr Hradsky
Processor Expert Support and Servicepacks Team


 

0 Kudos