cancel
Showing results for 
Search instead for 
Did you mean: 

PID with SIMD Intrinsics on CM4 and CM7 with hard FPU

sean thakur_2
Associate II
Posted on July 19, 2017 at 04:19

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_q15

I 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
4 REPLIES 4
Posted on July 19, 2017 at 14:48

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...)

Posted on July 20, 2017 at 00:11

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 19, 2017 at 22:37

Yes indeed, I am specifying in my GNU makefile:

-mfloat-abi

=hard

-mfpu

=fpv4-sp-d16

-march

=armv7e-m

-fsingle-precision-constant

Posted on July 20, 2017 at 00:28

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..