STMicroelectronics / STM32CubeL4

STM32Cube MCU Full Package for the STM32L4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
259 stars 151 forks source link

Included CMSIS DSP library outdated #81

Closed MartinKliemank closed 11 months ago

MartinKliemank commented 1 year ago

ARM CMSIS DPS libary in this package seems to be outdated:

c:\st\stm32cubeide_1.6.0\stm32cubeide\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.10.3-2021.10.win32_1.0.200.202301161003\tools\arm-none-eabi\bin\ld.exe: ./Core/Src/main.o: in function `main':
C:/Users/xxxx/STM32CubeIDE/workspace_1.6.0/ViBES_MBED/Debug/../Core/Src/main.c:209: undefined reference to `arm_weighted_sum_f32'

` __STATIC_FORCEINLINE float32_t arm_linear_interp_f32( arm_linear_interp_instance_f32 S, float32_t x) { float32_t y; float32_t x0, x1; / Nearest input values / float32_t y0, y1; / Nearest output values / float32_t xSpacing = S->xSpacing; / spacing between input values / int32_t i; / Index variable / float32_t pYData = S->pYData; / pointer to output table /

/* Calculation of index */
i = (int32_t) ((x - S->x1) / xSpacing);

**if (i < 0)**
{
  /* Iniatilize output for below specified range as least output value of table */
  y = pYData[0];
}
**else if ((uint32_t)i >= S->nValues)**
{
  /* Iniatilize output for above specified range as last output value of table */
  y = pYData[S->nValues - 1];
}
else
{
  /* Calculation of nearest input values */
  x0 = S->x1 +  i      * xSpacing;
  x1 = S->x1 + (i + 1) * xSpacing;

  /* Read of nearest output values */
  y0 = pYData[i];
  y1 = pYData[i + 1];

  /* Calculation of output */
  y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));

}

/* returns output value */
return (y);

} `

the described workings outside the range only apply once i is more than 1 outside the range, vs the fixed version at https://github.com/ARM-software/CMSIS-DSP/blob/main/Source/InterpolationFunctions/arm_linear_interp_f32.c :

` float32_t arm_linear_interp_f32( arm_linear_interp_instance_f32 S, float32_t x) { float32_t y; float32_t x0, x1; / Nearest input values / float32_t y0, y1; / Nearest output values / float32_t xSpacing = S->xSpacing; / spacing between input values / int32_t i; / Index variable / const float32_t pYData = S->pYData; / pointer to output table /

/* Calculation of index */
i = (int32_t) ((x - S->x1) / xSpacing);

**if (x < S->x1)**
{
  /* Iniatilize output for below specified range as least output value of table */
  y = pYData[0];
}
**else if ((uint32_t)i >= (S->nValues - 1))**
{
  /* Iniatilize output for above specified range as last output value of table */
  y = pYData[S->nValues - 1];
}
else
{
  /* Calculation of nearest input values */
  x0 = S->x1 +  i      * xSpacing;
  x1 = S->x1 + (i + 1) * xSpacing;

  /* Read of nearest output values */
  y0 = pYData[i];
  y1 = pYData[i + 1];

  /* Calculation of output */
  y = y0 + (x - x0) * ((y1 - y0) / (x1 - x0));

}

/* returns output value */
return (y);

} `

How To Reproduce

I included the CMSIS DSP library from this repository in STM32 CUBE IDE by following this tutorial: https://community.st.com/t5/stm32-mcus/configuring-dsp-libraries-on-stm32cubeide/ta-p/49637

And used it like this:

#include "arm_math.h" ... arm_linear_interp_instance_f32 S = {k_i[k][1] - k_i[k][0] + 1, f_i[k][0], f_i[k][1] - f_i[k][0], &p_i[k][0]}; for (int j = 0; j < length_f_K; j++){ p_temp[k][j] = arm_linear_interp_f32(&S, f_i[K-1][j]); } ... float sum = arm_weighted_sum_f32(&p_temp2[k][0], helper, length_f_K);

(I hope this is the right place and format for this, most of the template didn't seem applicable)

TOUNSTM commented 1 year ago

Hello @MartinKliemank,

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards,

TOUNSTM commented 11 months ago

Hello @MartinKliemank,

Unfortunately, there is no plan to update CMSIS DSP library in the short term. I will keep you informed if there are any updates. Please allow me to close this issue.

Thank you in advance for your comprehension.

Best Regards,

MartinKliemank commented 11 months ago

Thank you for the update @TOUNSTM . Then, however, I must ask you (or ST in general) to provide a new tutorial to replace the one linked above on how to properly include CMSIS DSP in STM CUBE IDE projects, since the current one relies on the version provided in this repository.