I am getting the C12056 warning for the following function.The fuction works perfectly. Can someone explain what is wrong ?
int16_t Interpolate3D(uint16_t *table, uint8_t axisXCnt, uint8_t axisYCnt, uint16_t xAxis, uint16_t yAxis)
{
uint8_t x, y;
int16_t Q11, Q12, Q21, Q22;
int32_t val1, val2;
int32_t interpVal;
float ratioX, ratioY;
x = 0;
y = 0;
Q11 = 0; // x-axis minimum interpolation value
Q12 = 0; // x-axis maximum interpolation value
Q21 = 0;
Q22 = 0;
if (xAxis <= table[0] || xAxis >= table[axisXCnt - 1])
{
if (xAxis <= table[0]) // less than minimum x value in table?
{
Q11 = table[0];
Q12 = table[1];
xAxis = Q11; // adjust to minimum value
x = 0; // AG just to make sure
}
if (xAxis >= table[axisXCnt - 1]) // greater than maximum x value in table?
{
Q11 = table[axisXCnt - 2];
Q12 = table[axisXCnt - 1];
xAxis = Q12; // adjust to maximum value
x = axisXCnt - 2; // AG addition, index to last but one element of x axis
}
}
else // locate table entries that surround xAxis value
{
for (x = 0; x < axisXCnt; x++)
{
if (table[x] <= xAxis && xAxis < table[x + 1])
{
Q11 = table[x];
Q12 = table[x + 1];
break;
}
}
}
ratioX = (float)(xAxis - Q11) / (float)(Q12 - Q11);
if ((yAxis <= table[axisXCnt]) || (yAxis >= table[(axisXCnt << 1) - 1]))
{
if (yAxis <= table[axisXCnt])
{
Q11 = table[axisXCnt];
Q12 = table[axisXCnt + 1];
yAxis = Q11;
y = 0; // AG just to make sure
}
else
{
Q11 = table[(axisXCnt << 1) - 2];
Q12 = table[(axisXCnt << 1) - 1];
yAxis = Q12;
y = axisYCnt - 2;
}
}
else
{
for (y = 0; y < axisYCnt; y++) // AG comment - should be axisYCnt-1 but probably works as-is
{
if ((table[y + axisXCnt] <= yAxis) && (yAxis <= table[y + axisXCnt + 1]))
{
Q11 = table[y + axisXCnt];
Q12 = table[y + axisXCnt + 1];
break;
}
}
}
y += 2; // offset so that index points to correct real data row
ratioY = (float)(yAxis - Q11) / (float)(Q12 - Q11);
Q11 = table[x + (axisXCnt * y)];
Q12 = table[x + (axisXCnt * y) + 1];
Q21 = table[x + (axisXCnt * (y + 1))];
Q22 = table[x + (axisXCnt * (y + 1)) + 1];
val1 = Q11 + (ratioX * (Q12 - Q11));
val2 = Q21 + (ratioX * (Q22 - Q21));
interpVal = val1 + (ratioY * (val2 - val1));
return (int16_t)interpVal;
}
Ray.
Hi Ray.
I just attached document about C12056, please check if you can sort out your problem with it.
if can't please provide your demo project, we need reproduce it and will work on it directly.
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------