Other Parts Discussed in Thread: CONTROLSUITE
Hi,
I am looking for a fast way to convert the fraction of an IQ style long integer number to a float for a subsequent __cospuf32() TMU intrinsic call.
I am in doubt how much IQ math support is in the F28075 (No ROM tables, right?). I tried the following:
#include "IQmathLib.h"
#include <math.h>
typedef float float32_t;
float32_t x, y, z;
int32_t lq16val = 0x0003c000; /* 3.75 */
int32_t t0, t1, t2, t3;
float32_t (*lq2f)(int32_t) = _IQ16toF; /* use a function pointer that points to the right IQxxtoF function if Q changes */
#define LQ16_MASK_FRACTION ((1L << 16) - 1)
void
test_tmu()
{
t0 = CpuTimer0Regs.TIM.all;
x = ldexp((float32_t)(lq16val & LQ16_MASK_FRACTION), -16);
t1 = CpuTimer0Regs.TIM.all;
y = _IQ16toF(lq16val & LQ16_MASK_FRACTION);
t2 = CpuTimer0Regs.TIM.all;
z = (*lq2f)(lq16val & LQ16_MASK_FRACTION);
t3 = CpuTimer0Regs.TIM.all;
t0 = t0 - t1; // 70 cycles
t1 = t1 - t2; // 32 cycles
t2 = t2 - t3; // 37 cycles
x = __sinpuf32(z); // etc.
}
I linked with the C:\ti\controlSUITE\libs\math\IQmath\v160\lib\IQmath_fpu32.lib, I received warnings on build:
warning #16002-D: build attribute vendor section TI missing in "J:\workspace\firmware\c2000\libc2000\lib\IQmath_fpu32.lib<IQ16toF.obj>": compatibility cannot be determined
warning #10247-D: creating output section "IQmath" without a SECTIONS specification
The results computed are correct (x == y == z = 0.75).
My questions are:
What with IQ math on the 28075?
Any better idea to do the job (faster!)? I searched in the Table 7-[6-8]. TMS320C28x C/C++ Compiler Intrinsics in the SPRU514L TMS320C28x Optimizing C/C++ Compiler Guide, but did not found anything appropriate.
Thanks,
Frank