2025-03-23 4:46 PM
Excuse me. I have some trouble in CORDIC function.
I Config CORDIC by Q1.31 for input and output data format. CORDIC can't work and the return data is right.
But I change the CORDIC input data to Q1.15 in config, It can't work. I always get 0.
Below is my config ...
LL_CORDIC_Config(CORDIC, LL_CORDIC_FUNCTION_COSINE, /* cosine function */
LL_CORDIC_PRECISION_4CYCLES, /* max precision for q1.31 cosine */
LL_CORDIC_SCALE_0, /* no scale */
LL_CORDIC_NBWRITE_1, /* One input data: angle. Second input data (modulus) is 1 after cordic reset */
LL_CORDIC_NBREAD_1, /* One output data: cosine, then sine */
LL_CORDIC_INSIZE_16BITS, /* q1.15 format for input data */
LL_CORDIC_OUTSIZE_16BITS); /* q1.15 format for output data */
and this is send data to CORDIC
tempf = input_degree /180.0f;
if(tempf > 1)
{
tempf = tempf-2;
}
else if(tempf <-1)
{
tempf = tempf+2 ;
}
temp_16 = (float)tempf * 32768; //for 16bit
ANGLE_CORDIC = (temp_16); //for 16bit input
/* Write angle */
LL_CORDIC_WriteData(CORDIC, ANGLE_CORDIC);
temp_32= (int32_t)LL_CORDIC_ReadData(CORDIC);
cos_value = (float)((int16_t)(temp_32 & 0xFFFF)) / 32768;
sin_value = (float)(temp_32 >>16) / 32768;
How to modify it to work for Q1.15 input data format? Thank you.