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.
Hi,
I need to know what will happen if my configuration of EPWM as mention below
INTSEL = 1 (Genrate interrupt on CTR=0);
CMPA Load Mode is shadow on CTR=0;
If I update CMPA value in ISR which value will be taken for compare previous or current? In other words first ISR will generate or CMPA value will get update?
Epwm1_ISR() // genrating on CTR=0
{
//CMPA loading here, so current will go to active register which I am loading here or previous one which was loaded in shadow register in last interrupt?
}
I think in this case it get delayed one period?
In control suite example of HVACI_Scalar, in this example they are using configuration like above I think in that case three phase sinusoidal PWM generation will get delayed by one period? I have mention example configuration below.
/*************************************************************************************************************/
// Enable CNT_zero interrupt using EPWM1 Time-base
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable EPWM1INT generation
EPwm1Regs.ETSEL.bit.INTSEL = 1; // Enable interrupt CNT_zero event
EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate interrupt on the 1st event
EPwm1Regs.ETCLR.bit.INT = 1; // Enable more interrupts
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM1_INT = &MainISR;
EDIS;
/*----------------------------------------------------------------------------
Initialization constant for the F2803X Compare Control Register.
----------------------------------------------------------------------------*/
#define CMPCTL_INIT_STATE ( LOADAMODE_ZRO + \
LOADBMODE_ZRO + \
SHDWAMODE_SHADOW + \
SHDWBMODE_SHADOW )
//MainISR
interrupt void MainISR(void)
{
// ------------------------------------------------------------------------------
// Connect inputs of the SVGEN_MF module and call the space-vector gen. macro
// ------------------------------------------------------------------------------
svgen_mf1.Gain = vhz1.VoltOut;
svgen_mf1.Freq = vhz1.Freq;
SVGENMF_MACRO(svgen_mf1);
// ------------------------------------------------------------------------------
// Connect inputs of the PWM_DRV module and call the PWM signal generation macro
// ------------------------------------------------------------------------------
pwm1.MfuncC1 = svgen_mf1.Ta;
pwm1.MfuncC2 = svgen_mf1.Tb;
pwm1.MfuncC3 = svgen_mf1.Tc;
PWM_MACRO(1,2,3,pwm1) // Calculate the new PWM compare values
}
Shubham,
With shadow loading writes are delayed up to a period. In this case whatever was written in CMPA before the CTR = 0 should be loaded.
If you update the CMPA value inside of the ISR, this will occur after the shadow load. Therefore it will not take affect until the next cycle's shadow load.
Regards,
Cody
Hi,
Thanks for the reply!
I have same doubt mention below and need more explanation.
In control suite example of HVACI_Scalar (ti\controlSUITE\development_kits\HVMotorCtrl+PfcKit_v2.1\HVACI_Scalar), in this example they are using configuration like which I asked in thread above (CMPA Loading and Generating ISR for CMPR update both on CTR -= 0) I think in that case three phase PWM generation will get delayed by one period (old sample value will compare)? I have mention example configuration below.
Please go through it and let me know in this example also pwm will be delayed or not by one period? If it is delayed then will it create any performance problem in rotating motor?
/*************************************************************************************************************/
// Enable CNT_zero interrupt using EPWM1 Time-base
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable EPWM1INT generation
EPwm1Regs.ETSEL.bit.INTSEL = 1; // Enable interrupt CNT_zero event
EPwm1Regs.ETPS.bit.INTPRD = 1; // Generate interrupt on the 1st event
EPwm1Regs.ETCLR.bit.INT = 1; // Enable more interrupts
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM1_INT = &MainISR;
EDIS;
/*----------------------------------------------------------------------------
Initialization constant for the F2803X Compare Control Register.
----------------------------------------------------------------------------*/
#define CMPCTL_INIT_STATE ( LOADAMODE_ZRO + \
LOADBMODE_ZRO + \
SHDWAMODE_SHADOW + \
SHDWBMODE_SHADOW )
//MainISR
interrupt void MainISR(void)
{
// ------------------------------------------------------------------------------
// Connect inputs of the SVGEN_MF module and call the space-vector gen. macro
// ------------------------------------------------------------------------------
svgen_mf1.Gain = vhz1.VoltOut;
svgen_mf1.Freq = vhz1.Freq;
SVGENMF_MACRO(svgen_mf1);
// ------------------------------------------------------------------------------
// Connect inputs of the PWM_DRV module and call the PWM signal generation macro
// ------------------------------------------------------------------------------
pwm1.MfuncC1 = svgen_mf1.Ta;
pwm1.MfuncC2 = svgen_mf1.Tb;
pwm1.MfuncC3 = svgen_mf1.Tc;
PWM_MACRO(1,2,3,pwm1) // Calculate the new PWM compare values
}
Your understanding is correct. In reality mechanical systems respond slowly to inputs relative to the speed of your control loop.
If you do not use shadow loading you risk missing an event for an entire PWM period, which has a much larger affect on the system.
Regards,
Cody
Hi,
I got it, still I have one doubt as you said "If you do not use shadow loading you risk missing an event for an entire PWM period, which has a much larger affect on the system". I did not get it, if I use Immediate load why it will miss the event?
And I run the motor by changing this configuration to immediate load, motor creating sound not running properly, according to you it is missing the the event.
Regards,
Shubham
Shubham,
Shubham Kant Dubey said:got it, still I have one doubt as you said "If you do not use shadow loading you risk missing an event for an entire PWM period, which has a much larger affect on the system". I did not get it, if I use Immediate load why it will miss the event?
The PWM module preforms an "equal to" compare it does not preform a "greater than or equal to" compare. So if your CMPA value is changed from 800 to 200 while the TBCTR = 201 then the CMPA event will be missed. The CMPA action will not take affect until the next period. If you do not use shadow load you will need to ensure that this does not happen in software.
Shubham Kant Dubey said:And I run the motor by changing this configuration to immediate load, motor creating sound not running properly, according to you it is missing the the event.
I am not trying to imply that this is the cause of your issue, it is merely an affect that you may or may not be experiencing due to not using shadow load. If your motor is not running there are many many issues that could be occurring, for example your control loop may not be tuned correctly.
Regards,
Cody