Tool/software: Code Composer Studio
Dear team,
In this doc, we use Q15_ATAN. Now the customer wants to change it to Q10. How to do that?
Please help.
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: Code Composer Studio
Dear team,
In this doc, we use Q15_ATAN. Now the customer wants to change it to Q10. How to do that?
Please help.
Which TI device is being used?
Thanks and regards,
-George
Susan,
We announced End-of-Life for this device way back in 2012. The entire toolchain for this device has been obsolete for several years already. As such, our ability to provide any kind of support to this device is very limited. We have reached out to the author of the app.note to explore if any support is possible. Your patience is appreciated.
Hello Susan,
thank you for your interest in the Application Report SPRA496.
I wrote the Assembly code only for Q15 fractional numbers. The function "int q15p_atan(int)" returns the angle scaled by PI in the range from 0 to PI/4. Hence the return value 0x000 = 0.0 (Q15) equals 0 degree and 0x2000 = 0.25 (Q15) equals PI/4 (45 degree). The Q15 gives the highest possible resolution, as also the input argument is scaled as Q15 from 0 to 0x7FFF (0.999).
Unfortunately I won't be able to rewrite the TMS320F240 Assembly code to Q10 format anymore.
However you may change yourself. Then you may consider the product shift mode SPM.
The code I used is written for SPM=1 (see assembly instruction) to handle Q15xQ15=Q30. With the automatic product shift mode (SPM 1) the product is automatically left shifted by 1 bit = Q31 so the resulting Q15 number is in the upper 16-bit of the 32-bit ACC (store ACCH).
When you go for Q10 then a multiplication product gives you Q10xQ10=Q20. To get a Q10 equivalent result in the upper 16-bit of the ACC you need an product shift mode by 11. I think SPM 11 is not supported by the F240 DSP core, but please check. Another option to get a Q10 results: You can instead right shift the 32-bit intermediate results by 10 so the Q10 scaled product is in the lower 16-bit of the ACC. In that case SPM needs to be 0. But please be aware you may get overflow as Q10xQ10 can exceed the Q10 range of +/-32.0.
Regards,
Martin Staebler
Hello Susan,
the atan(x), where x can be from 0 to 1.0, is a nonlinear function and as as such the lookup table is nonlinear too. The lookup table is basically an 8-bit approximation of the atan(x) function. The argument x is right shifted to get an 8-bit equivalent pointer to the corresponding approximate angle value in the lookup table.
Example:
atan(0): 0 is converted to 0 and points to the first element in the lookup table: 0
atan(1.0): 1.0 is converted to 128 and points to the last (129) element in the lookup table: 8192=0.25 Q15 (equals PI*0.25=45deg)
atan(0.5): 0.5 is converted to 64 and points to the 65 element in the lookup table: 4836=0.149 Q15 (equals P*0.1475= 26.56deg)
atan(0.25): 0.25 is converted to 32 and points to the 33 element in the lookup table: 2555=0.077 Q15 (equals P*0.077= 14.03deg)
and so on.
Does this answer your question?
Regards,
Martin Staebler