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 "MRF1SP_Func_MFR"?
I tried to do it like shown below:
void main(void)
{
Frac16 r;
PE_low_level_init();
for(;
{
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
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