This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ILLEGAL_ISR instead function using PID library with CCS 4

Hello!

I'm trying to tranin with CCS 4 ( 4.0.2.01003 ) for a stepper motor driving application.

I'm using Piccolo experimental kit with 28035 processor, connected with a custom power board. I started from Piccolo-B header e peripheral control library, sprc892, to gain acces to various modules. In particular, I've PWM and ADC running.Then I tried to use PID library, with no success.

I loaded "${workspace_loc:/iqDMC_ml}" as project in workspace and compiled as library.

I included math functions folders in c2000 compiler -> include options

"${workspace_loc:/iqDMC_ml}"

"C:\TI_F28xxx_SysSW\~SupportFiles\lib\DMClib\cIQmath\include"

"C:\TI_F28xxx_SysSW\~SupportFiles\lib\IQmath\cIQmath\include"

and included library in c2000 linker->file search path > include library file as input box

"${workspace_loc:/iqDMC_ml/Debug/iqDMC_ml.lib}"

(it worked well with 2xPM_Motors demo)

then I Added .h

#define GLOBAL_Q 15 /* Set the Local Q value */
#include "IQmathlib.h"
#include "pid_reg3.h"

initialized pid in main

   // init pid
   pid1.Kp = _IQ(0.5); // Pass _iq parameters to pid1
pid1.Ki = _IQ(0.001); // Pass _iq parameters to pid1
pid1.Kd = _IQ(0.01); // Pass _iq parameters to pid1
pid1.Kc = _IQ(0.9); // Pass _iq parameters to pid1

then I use pid in a function called in an ISR

             pid1.Ref = _IQ(0.2); // Pass _iq inputs to pid1
            pid1.Fdb = _IQ(0.15); // Pass _iq inputs to pid1
            pid1.calc(&pid1); // Call compute function for pid1

At pid1.calc it don't run the right funcion, but I fall in  ILLEGAL_ISR

Any suggestion?

Regards, Loriano.

  •  

    I found a solution.

     

    Thanks however.

  • hi,Loriano Galeotti

    I'm confronting the same problem ,could you be kind enough to tell me how you solve this tricky problem?

    Could you send me a mail to kfmuzik@126.com  with the solution to this problem?

    Thanks a lot!

  • If I remember well, I did a mistake in function for cla code copy.

    You must copy your CLA code to RAM at runtime using a function like these in your code:

    // Copy time critical code and Flash setup code to RAM
    // This includes the following ISR functions: cla1_isr7 and InitFlash();
    // The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
    // symbols are created by the linker. Refer to the F2808.cmd file.
    //
      MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);

    // copy CLA functions to RAM
      MemCopy(&Cla1funcsLoadStart, &Cla1funcsLoadEnd, &Cla1funcsRunStart);   

    I used linker command file from example  cla_adc_fir_flash in   2803x C/C++ Header Files and Peripheral Examples Quick Start  - Version 1.21

    http://focus.ti.com/docs/toolsw/folders/print/sprc892.html

    I hope it helps.

    Bye, Loriano.


  • Hi,Loriano,

    thanks for your timely advice, but could you be kind enough to tell  me what is ' CLA functions'? Could you give me a example or tell me where i can find this function?

    Best wishes!

     

    kfmuzik

     

  • Hi !

    I like when people help me so I try to help people when I can :)

    However, I think you are talking about "RamfuncsLoadStart" and the other constants used from MemCopy.

    These are defined in the linker commad file. I'ven't investigated too much how it works, just taken from the example :) .  If you install the sprc892  use the example

    C:\tidcs\c28\DSP2803x\v121\DSP2803x_examples_ccsv4\cla_adc_fir_flash

    constants are correctly set from the F28035_CLA_lnk.cmd linker commad file. You have just to include it in project, set the compiler switch to use the CLA (howto is written somewhere in the forum or wiki page) and in the main use the memcopy funcs, configure CLA (see the following), and it should work. 

      EALLOW;  // This is needed to write to EALLOW protected register
      
    // configure cla
       Cla1Regs.MVECT1 = (Uint16) (&Cla1Task1 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT2 = (Uint16) (&Cla1Task2 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT3 = (Uint16) (&Cla1Task3 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT4 = (Uint16) (&Cla1Task4 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT5 = (Uint16) (&Cla1Task5 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT6 = (Uint16) (&Cla1Task6 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT7 = (Uint16) (&Cla1Task7 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MVECT8 = (Uint16) (&Cla1Task8 - &Cla1Prog_Start)*sizeof(Uint32);
       Cla1Regs.MPISRCSEL1.bit.PERINT2SEL = CLA_INT2_ADCINT2; // ADCINT2 starts Task 2
       Cla1Regs.MPISRCSEL1.bit.PERINT3SEL = CLA_INT3_ADCINT3; // ADCINT3 starts Task 3
       Cla1Regs.MMEMCFG.bit.PROGE = 1;          // Map CLA program memory to the CLA
       Cla1Regs.MCTL.bit.IACKE = 1;             // Enable IACK to start tasks via software

     

    ... of course.. I suggest to start from example, it would be easier :)

    Bye, Loriano.