AnsweredAssumed Answered

CMSIS DSP compilation error & Struct Initialization

Question asked by slimsly on Mar 9, 2013
Latest reply on Sep 30, 2013 by Clive One
Hello,

I am  trying to implementing PID in Systick Interrupt handler.I get this error after compilation in Keil MDK " C:\Keil\ARM\CMSIS\Include\arm_math.h(268): error:  #5: cannot open source input file "ARMCM4.h": No such file or directory". I added arm_cortexM3l_math.lib to my Project List but no Luck.I need help in this aspect.Also, I think I have a problem with Initailizing Kp, Ki & Kd " arm_pid_instance_q15 " struct.Please can someone tell me if  my inialization is correct and if I did the right thing on CMSIS PID.

-------------------------  
/**
   * @brief Instance structure for the Q15 PID Control.
   */
  typedef struct
  {
    q15_t A0;    /**< The derived gain, A0 = Kp + Ki + Kd . */
#ifdef ARM_MATH_CM0
    q15_t A1;
    q15_t A2;
#else
    q31_t A1;           /**< The derived gain A1 = -Kp - 2Kd | Kd.*/
#endif
    q15_t state[3];       /**< The state array of length 3. */
    q15_t Kp;           /**< The proportional gain. */
    q15_t Ki;           /**< The integral gain. */
    q15_t Kd;           /**< The derivative gain. */
  } arm_pid_instance_q15;
------------------

MY CODE WITH COMPILATION ERROR
------------------
#include "stm32f10x.h"
#include "arm_math.h"


int main(void)
 {
    uint16_t SpeedError,CorrectedSpeed;    /* Variable that holds error*/
  uint_16 resetStateFlag = 0;
    
      RCC->APB2ENR |= RCC_APB2ENR_AFIOEN | RCC_APB2ENR_IOPBEN;
        //PB0 & PB1 =>Alt Function Push Pull O/P | PB6-PB7 Alt Function Open Drain
    GPIOB->CRL = 0xFF4444AA;
    GPIOB->CRH = 0x44441111;    //Configure PB8-PB11 as Output (Push Pull)
      GPIOB->ODR = 0x00000000;
    
    arm_pid_instance_q15 S;  /* PID S Instance Structure*/
  S.Kp = 2300;             /* Change the member Kp of S to have the value of 2300 */
  S.Ki = 150;              /* Change the member Ki of S to have the value of 150 */
  S.Kd = 0                 /* Change the member Kd of S to have the value of 0 */
    
    arm_pid_reset_q15(&S);   /*resets the state buffer to zeros*/   
  arm_pid_init_q15 = {&S, resetStateFlag}; /* Initialize A0 & A1 from Kp, Ki & Kd */
    
    if (SysTick_Config(SystemCoreClock / 1000))
      {
      /* Capture error */
        while(1);
        }
      while(1)
        {
       
        }
 }

Regards
Slim

void SysTick_Handler(void)
 {    
  CorrectedSpeed = __STATIC_INLINE q15_t arm_pid_q15(&S,SpeedError); /*PID out processed output sample*/   
 }

Outcomes