This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
hi
We would like to have a code example for using the MATHACL for the square root operation. Unfortunately, there is no example in the SDK.
may you help?
thx
Vincenzo
Hello Vincenzo,
I am sorry that we don't have the example. Please refer to the TRM and generate it. There are detailed guide on TRM about how to use the MATHACL.
Best Regards,
Janz Bai
hi Janz Bai,
thx a lot. So no plan to make a little example in the SDK, correct?
just to be sure...
thx
Vincenzo
Hello Vincenzo,
I remember that there is no plan to add this in SDK now.
Best Regards,
Janz Bai
hi Janz Bai,
I would like to know the steps to calculate the square root of a simple number like 9.
I tried the following method, but it didn't work. Could you please point out what I did wrong?
MATHACL->CTL = MATHACL_CTL_FUNC_SQRT | // Do square root
MATHACL_CTL_OPTYPE_UNSIGNED | // The operand is unsigned
MATHACL_CTL_QVAL_Q0; // No fractional
MATHACL->OP1 = 9U;
MATHACL->OP2 = 0U;
while ((MATHACL->STATUS & MATHACL_STATUS_BUSY_MASK) == MATHACL_STATUS_BUSY_NOTDONE) {
;
}
result = MATHACL->RES1;
thx
Vincenzo
Hello Vincenzo,
My HSM colleague will help you on this issue.
Best Regards,
Janz Bai
Hi, Vincenzo
For QURT function, please refer to this section first:
https://www.ti.com/lit/ug/slau846b/slau846b.pdf
6.4.3 Square Root (SQRT)
If you have any question about these steps, please feel free to ask me.
Regards,
Helic
Hi Helic,
from the square root step.
I calculated as below scaled number
uint32_t sqrtNumber = 100 ; // Lets find the square root of 100
Best Regards
Tulsi Das
Hi Helic,
I got the answer in my way2.
I found mistake in my earlier code .
DL_GPIO_setValueCTL(MATHACL, (0xffffffe5 & 0xe1ffffff & (0xffe0ffff|(SFACTOR << 16)))) ; // Set Function squareroot
In this line, 0xffe0ffff|(SFACTOR << 16). It must be be 0xffc0ffff|(SFACTOR << 16). Because SFACTOR need 6 bit.
I feel happy if you could explain how to use : DL_MathACL_startSqrtOperation(MATHACL, config, sqrt) ;
I have problem to use this SFACTOR while calling SQRT function. I need your help how to use it?
Best Regards
Tulsi Das
Hi, Tulsi Das and Vincenzo Pizzolante
Here is the SQRT operation code example:
mathacl_sqrt_op_LP_MSPM0G3507_nortos_ticlang.zip
Regards,
Helic