你好 请问一下 这个文档的第 37页开始 Q15_ATAN.INC 文档里面的 反正切表的生成方法 我想改一个 Q10格式的
我不太明白 这个表是怎么生成的 方便告诉我嘛 谢谢
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.
回复 Susan Yang:
Thank you for your answers,
I don't know if that's right
The 0-0.99 Q15 format corresponds to 0-32768
The 0-0.25 Q15 format corresponds to the 0-pi / 4-> 0-8192 45 degree subdivision into 128 pieces
45/128 = 0.3515625 degree
table degree =
Here is SPRA496 document Q15_ATAN
I don't understand table = 81?table = 163 ?
table = 8151?
What is the generation pattern of the above table elements?
How is this part of the value generated
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.
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.