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.

example of multi-task in CLA

Other Parts Discussed in Thread: TMS320F28035, CONTROLSUITE

Hi,

I use TMS320F28035 MCU. 

I am trying to use two tasks in the CLA. I started with the cla_adc example from controlSUITE. In the example, it uses epwm to trigger ADC, and use ADC interrupt to trigger CLA task. It shows that you don't have to implement Adc_ISR, as long as we set up the ADC interrupt, it should work. So, following the same method, I enabled another task of CLA, and it was triggered by an EPwm interrrupt. But, it was only working if I actually implement a EPwm_ISR ( ) even though there was no real job inside it but clear the flag and piectrl.

I think I should not have to do it this way. There should be a way to avoid writing EPwm_ISR( ). But I just could not get both tasks working without writing it.

All the examples from controlSUITE use only one peripheral interrupt to trigger one task and use software force for other tasks.

I just want to know how to set it up properly, so I can use two different peripheral interrupts to trigger two different tasks in CLA (without software force)

for example, using ADCINT1 to trigger task1, and using EPWM2_INT to trigger task2.

Could anyone show me how to configure it  or show me where I can find more examples ?

Thank you.

  • Hi Max,

    you can clear ETFLG.INT bit from within task 2 to enable further intrerrupt generation. you must use the ETCLR register for this.

    MMOVI32  MR0, #0x01

    MMOV16 @EPwm2Regs.ETCLR.all, MR0 ;Write a 1 to the INT bit field of ETCLR to enable interrupt generation

  • Hi Vishal,

    Thanks for your reply, but it is still not working.

    I will show what I have tried by modifying the " ClaAdc " example from controlSUITE, and hope you can point out where I did wrong.

    First, it is the source file ' Example_2803xClaAdc.c '

     

    #include "DSP28x_Project.h"  

     #include "CLAShared.h"

    interrupt void cla1_isr2(void);

    #pragma DATA_SECTION(ConversionCount, "Cla1ToCpuMsgRAM");

    #pragma DATA_SECTION(VoltageCLA,      "Cla1ToCpuMsgRAM");

    Uint16 ConversionCount;

    Uint16 LoopCount;

    Uint16 VoltageCLA[NUM_DATA_POINTS];

    extern Uint16 Cla1funcsLoadStart;

    extern Uint16 Cla1funcsLoadEnd;

    extern Uint16 Cla1funcsRunStart;

     

    main()

     {

       InitSysCtrl();

       DINT;

       InitPieCtrl();

       IER = 0x0000;   

       IFR = 0x0000;

       InitPieVectTable();

     

       EALLOW;    

       PieVectTable.CLA1_INT2 = &cla1_isr2;     

       EDIS;  

     

       InitAdc();       

     

       PieCtrlRegs.PIEIER11.bit.INTx2 = 1;        

       IER |= M_INT11;                           

       EINT;                      

       ERTM;                  

       MemCopy(&Cla1funcsLoadStart, &Cla1funcsLoadEnd, &Cla1funcsRunStart);   

      EALLOW;   

       Cla1Regs.MVECT2 = (Uint16) (&Cla1Task2 - &Cla1Prog_Start)*sizeof(Uint32);   

       Cla1Regs.MVECT8 = (Uint16) (&Cla1Task8 - &Cla1Prog_Start)*sizeof(Uint32);   

       Cla1Regs.MPISRCSEL1.bit.PERINT2SEL = CLA_INT2_EPWM2INT;   

       Cla1Regs.MMEMCFG.bit.PROGE = 1;           

       Cla1Regs.MCTL.bit.IACKE = 1;               

       Cla1Regs.MIER.all = (M_INT8 | M_INT2);    

       Cla1ForceTask8andWait();                

       AdcRegs.ADCSOC1CTL.bit.CHSEL    = 2;       

       AdcRegs.ADCSOC1CTL.bit.TRIGSEL  = 5;       

       AdcRegs.ADCSOC1CTL.bit.ACQPS    = 6;       

     EDIS;

       EALLOW;   

       SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;   

       EDIS;   

               EPwm1Regs.ETSEL.bit.SOCAEN = 1;     

               EPwm1Regs.ETSEL.bit.SOCASEL = 4;     

               EPwm1Regs.ETPS.bit.SOCAPRD  = 1;     

               EPwm1Regs.CMPA.half.CMPA  = 0x0080;    

               EPwm1Regs.TBPRD   = 0xFFFF;    

               EPwm1Regs.TBCTL.bit.CTRMODE  = 0;  

               EPwm1Regs.ETSEL.all = 0;  

               EPwm1Regs.ETSEL.bit.INTEN = 1;    

               EPwm1Regs.ETSEL.bit.INTSEL = 1;    

               EPwm1Regs.ETPS.bit.INTPRD = 1;  

       EALLOW;   

       SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;   

       EDIS;         

     

        for( ; ; )   

         {       LoopCount++;    }

     

    }

    interrupt void cla1_isr2 ( )

    {

        PieCtrlRegs.PIEACK.all = 0xFFFF;

    }

     

    // CLA.asm content is on next posting

  • Here is the content of the CLA.asm file:

     

          .cdecls   C,LIST,"CLAShared.h"

     

    CLA_DEBUG .set  1

     

          .sect    "Cla1Prog"     

          .align  2

     

    _Cla1Prog_Start:

    _Cla1Task1:    

    MSTOP    

    MNOP    

    MNOP    

    MNOP

    _Cla1T1End:

     

    _Cla1Task2:    

           .if CLA_DEBUG == 1        

            MDEBUGSTOP    

            .endif

    MMOVZ16    MR0,    @_ConversionCount                 ;1 Current Conversion    

    MMOV16     MAR1,   MR0,   #_VoltageCLA                ;2 Point to VoltageCLA[ConversionCount]    

    MUI16TOF32   MR0,   MR0                                         ;3 Convert count to float32    

    MADDF32    MR0,   MR0,   #1.0                                  ;4 Add 1 to conversion count    

    MCMPF32    MR0,     #NUM_DATA_POINTS.0          ;5 Compare count to max    

    MF32TOUI16   MR0,   MR0                                         ;6 Convert count to Uint16    

    MNOP                                                                          ;7 Wait till I8 to read result    

    MMOVZ16    MR2,     @_AdcResult.ADCRESULT1   ;8 Read ADCRESULT1    

    MMOV16     *MAR1,    MR2                                         ;  Store ADCRESULT1    

    MBCNDD     _RestartCount,    GEQ                            ;  If count >= NUM_DATA_POINTS    

    MMOVIZ     MR1,     #0.0                                             ;  Always executed: load MR1 with 0    

    MNOP    

    MNOP    

    MMOV16      @_ConversionCount,     MR0                  ;  If branch not taken, store current count

     

    MMOVI32     MR3,      #0x01    

    MMOV16      @_EPwm2Regs.ETCLR.all,      MR3

    MSTOP    

    MNOP    

    MNOP    

    MNOP

    _RestartCount

    MMOV16      @_ConversionCount,    MR1                  ;  If branch taken, restart count

    MMOVI32     MR3,   #0x01    

    MMOV16      @_EPwm2Regs.ETCLR.all,     MR3

    MSTOP    

    MNOP    

    MNOP    

    MNOP

    _Cla1T2End:

     

    ;------------------------------------------------------------------------------------

     Here represents Task3 to Task7 to save some space here

    ;------------------------------------------------------------------------------------

    _Cla1Task8:

        MMOVIZ  MR0,  #0.0    

        MMOV16  @_ConversionCount, MR0    

        MSTOP

    _Cla1T8End:

     

    _Cla1Prog_End:

        .end    

        .include "CLAShared.h"

  • Hi Vishal,

    Could you help me with this ? 

    Thanks.

  • Max

    You have configured EPWM 1 to provide the SOCA signal but you have setup CLA task 2 to trigger on interrupt from EPWM2

    Max Zhang said:

               EPwm1Regs.ETSEL.bit.SOCAEN = 1;     

               EPwm1Regs.ETSEL.bit.SOCASEL = 4;     

               EPwm1Regs.ETPS.bit.SOCAPRD  = 1;     

               EPwm1Regs.CMPA.half.CMPA  = 0x0080;    

               EPwm1Regs.TBPRD   = 0xFFFF;    

               EPwm1Regs.TBCTL.bit.CTRMODE  = 0;  

              EPwm1Regs.ETSEL.all = 0;  

               EPwm1Regs.ETSEL.bit.INTEN = 1;    

               EPwm1Regs.ETSEL.bit.INTSEL = 1;    

               EPwm1Regs.ETPS.bit.INTPRD = 1;  

    You need to change the above to EPWM2.

  • Hi Vishal,

    Thank you for pointing out that mistake. It is working if I use EPwm2 interrupt to trigger Task2.

    Now, I am trying to use ADCINT2 instead of EPwm2.

    I thought I could use the same method by simply  clearing the register ADCINTFLGCLR at the end of the task2 in CLA ( right before MSTOP).

    But it didn't work.

    Does it require more work than using EPwm2 ?

    Thank you.

  • Max, You can only access the ADC result registers from the CLA not the config regs. You can set it up so that the ADCINT2 not only triggers task 2 but also fires an interrupt to the PIE on the C28 and you can clear the flag in the isr ....or you can set the INTSEL1N2.INT2CONT bit to have the ADC ignore the flag when generating ADCINT2