2017-07-18 07:19 PM
This is perhaps more a CMSIS question
I am trying to build a PID application on STM32F4
CMSIS DSP version: V1.4.5 b
I included the 'libarm_cortexM4lf_math' for GCC, included 'arm_math.h'.
I enabled compile time flag ARM_MATH_CM4
I will be calling init, reset and process from my application code.
However, I was not able to build PID for Q15 type because of inability for find __SMUAD and other SIMD intrinsics
I &sharpif0 ed the
static
__INLINE q15_t arm_pid_q15I could compile the q31 and f32 methods. However, methods for 32-bit types do not actually use SIMD intrinsics, which makes me doubt if there is any CMSIS DSP value-add for them... Does anybody have an experience with PID on M4 or M7?
for e.g.
static
__INLINE q31_t arm_pid_q31(
arm_pid_instance_q31 * S,
q31_t in)
{
q63_t acc;
q31_t out;
/* acc = A0 * x[n]
*/
acc = (q63_t) S->A0 * in;
/* acc += A1 * x[n-1] */
acc += (q63_t) S->A1 * S->state[0];
/* acc += A2 * x[n-2]
*/
acc += (q63_t) S->A2 * S->state[1];
/* convert output to 1.31 format to add y[n-1] */
out = (q31_t) (acc >> 31u);
/* out += y[n-1] */
out += S->state[2];
/* Update state */
S->state[1] = S->state[0];
S->state[0] = in;
S->state[2] = out;
/* return to application */
return
(out);
}#pid #cmsis #m4-fpu #cmsis-dsp
2017-07-19 05:48 AM
Hello !
You must inform your compiler about your Floating point hardware you will use.
In project properties at your IDE you can choose between some options about FP functionality(hard or soft etc...)
2017-07-19 03:11 PM
Should be CM7 aware DSP libraries as part of the Cube/CMSIS trees.
I'll have to dig up my GNU/GCC makefile for building these, it's on a different box. The ABI has to match what you're binding it with
-mcpu=cortex-m4 -fno-strict-aliasing -ffunction-sections
ARM_MATH_CM4, ARM_MATH_MATRIX_CHECK, ARM_MATH_ROUNDING
2017-07-19 03:37 PM
Yes indeed, I am specifying in my GNU makefile:
-mfloat-abi
=hard
-mfpu
=fpv4-sp-d16-march
=armv7e-m-fsingle-precision-constant
2017-07-19 05:28 PM
See final post in thread below
https://community.st.com/0D50X00009Xki4PSAR
It is important that the libraries are built with a set of settings which are coherent with the rest of your project. Also make sure you have code to enable the FPU, this needs to be in the ResetHandler if you have extended instructions scattered throughout your code.
https://community.st.com/0D70X000006SIfWSAW
https://community.st.com/0D70X000006SHoESAW