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