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.

How to change the interrupt source of DPLib routine?

Other Parts Discussed in Thread: CONTROLSUITE

HI,

 

I am now using the template “C:\ti\controlSUITE\development_kits\TemplateProjects\DPLibv3_4Template-F2803x” inside the controlSUITE on my F28069 Piccolo Experimenter Kit.

 

Initially, I set the duty cycle of the ePWM2 to be 0.2 at the main()

Duty2A =_IQ24(0.2);

 

And then I add one more line at C1 task:

void C1(void)      

//------------------------------------------------------

{

     Duty2A =_IQ24(0.6);

 

     //-----------------

     //the next time CpuTimer2 'counter' reaches Period value go to C2

     C_Task_Ptr = &C2;

     //-----------------

 

}

 

I observed from the CRO that the duty of ePWM2 is 0.6, which is expected.

 

And then, I would like to change the interrupt source of DPLib from ePWM2 Int to ePWM4 Int. I made the following changes:

 

The external variable and variable inside main.c

// PWMDRV_1ch

extern volatile long *PWMDRV_1ch_Duty4;       // instance #2, EPWM4

volatile long Duty4A;

 

the init function of ePWM changed from 2 to 4

PWM_1ch_CNF(4, 300,0,0);

 

The init value inside main()

Duty4A =_IQ24(0.2);

 

The updated value inside C1 task:

Duty4A =_IQ24(0.6);

 

 

The Interrupt setting

// Set up C28x Interrupt

 

//Also Set the appropriate # define's in the {ProjectName}-Settings.h

//to enable interrupt management in the ISR

        EALLOW;

    PieVectTable.EPWM4_INT = &DPL_ISR;           // Map Interrupt

    EPwm4Regs.ETSEL.bit.SOCAEN     = 1;

     PieCtrlRegs.PIEIER3.bit.INTx4 = 1;            // PIE level enable, Grp3 / Int4

     EPwm4Regs.ETSEL.bit.INTSEL = ET_CTR_PRD;    // INT on PRD event

     EPwm4Regs.ETSEL.bit.INTEN = 1;              // Enable INT

    EPwm4Regs.ETPS.bit.INTPRD = ET_1ST;         // Generate INT on every event

 

    IER |= M_INT3;                             // Enable CPU INT3 connected to EPWM1-6 INTs:

    EINT;                                     // Enable Global interrupt INTM

    ERTM;                                           // Enable Global realtime interrupt DBGM

        EDIS;     

 

The Init and  the run time function inside ProjectName-DPL-ISR.asm

 

PWMDRV_1ch_INIT 4     ; PWM4A

 

 

PWMDRV_1ch 4              ; PWM4A

 

I observed from the CRO again and found that the duty of ePWM4 is 0.2 not 0.6, which implies the DPLib routine can only run one time, the updated value inside C1 task cannot be pass to the DPLib routine. I am pleasure if anyone can help, thank you.

 

Barry

  • Yes, the way you're updating the duty is erroneous. Can you attach the c file or screenshot?

    Regards,

    Gautam

  • Dear Gautam,

    Attached please find the files.

    BR,

    Barry

    5732.ProjectName-Main.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    //----------------------------------------------------------------------------------
    // FILE: ProjectName-Main.c
    //
    // Description: Sample Template file to edit
    // The file drives duty on PWM1A using CLA and PWM2 using C28x
    // These can be deleted and modified by the user
    // CLA Task is triggered by the PWM 1 interrupt
    // C28x ISR is triggered by the PWM 2 interrupt
    //
    // Version: 3.4
    //
    // Target: TMS320F2803x(PiccoloB)
    //
    //----------------------------------------------------------------------------------
    // Copyright Texas Instruments �2004-2010
    //----------------------------------------------------------------------------------
    // Revision History:
    //----------------------------------------------------------------------------------
    // Date | Description / Status
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    0020.ProjectName-DPL-ISR.asm

    Gautam Iyer said:

    Yes, the way you're updating the duty is erroneous. Can you attach the c file or screenshot?

    Regards,

    Gautam

    Gautam Iyer said:

    Yes, the way you're updating the duty is erroneous. Can you attach the c file or screenshot?

    Regards,

    Gautam

  • Hello Barry!

    I have looked at your C-file. It seems you do something wrong.

    1

    // Connect the PWM Driver input to an input variable, Open Loop System
    PWMDRV_1ch_Duty4 = &Duty4A;

    // Initialize the net variables
    CLA_Duty1 =(float32)(0.5);// Why not 0.4? 
    Duty4A =_IQ24(0.2);//  if you want 0.6 then you should paste Duty4A =_IQ24(0.6);


    2

    //Also Set the appropriate # define's in the {ProjectName}-Settings.h
    //to enable interrupt management in the ISR
    EALLOW;
    PieVectTable.EPWM4_INT = &DPL_ISR; // Map Interrupt
    EPwm4Regs.ETSEL.bit.SOCAEN = 1;// Why do you do that? This was not in the source file ProjectName-Main.c.
    PieCtrlRegs.PIEIER3.bit.INTx4 = 1; // PIE level enable, Grp3 / Int2
    EPwm4Regs.ETSEL.bit.INTSEL = ET_CTR_PRD; // INT on PRD event
    EPwm4Regs.ETSEL.bit.INTEN = 1; // Enable INT
    EPwm4Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on every event

    void C1(void)
    //------------------------------------------------------
    {
    Duty4A =_IQ24(0.6);// You should comment this line

    //-----------------
    //the next time CpuTimer2 'counter' reaches Period value go to C2
    C_Task_Ptr = &C2;
    //-----------------

    }

     4

    Maybe I don't understand what do you wish and I'm wrong.

    Regards,

    Igor

  • HI Igor,

    Sorry that maybe I explain not clear. Let me describe the objective of the program:

    The purpose of this program is to test whether the DPLib routine can execute or not during runtime. To verify this, I add Duty4A =_IQ24(0.2); inside the main() and Duty4A =_IQ24(0.6) inside the C1(). If the DPLib routine can execute, the duty cycle of that ePWM will eventually change to from 0.2 to 0.6.

     

    At the beginning, I used ePWM1 and its interrupt to trigger the DPLib ISR. The duty is eventually changed to 0.6 observed by CRO.

     

    And then, I would like to use ePWM4 and its interrupt to trigger the DPLib ISR. I changed all necessary variables and registers. This time, I found that the duty is 0.2 not 0.6.

    Regarding Q2: EPwm4Regs.ETSEL.bit.SOCAEN = 1;// Why do you do that? This was not in the source file ProjectName-Main.c.

     

    I tried comment and uncomment this code, the result is the same. The problem should not come from this line, please ignore.

     

    Regarding Q2: CLA_Duty1 =(float32)(0.5);// Why not 0.4?, This is the duty of ePWM1 using CLA, the value of this will not affect this test.

     

    BR,

    Barry