TMS320F28379D: tms320f28379d

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software:

I am trying to modify this code for closed loop peak current mode operation of the four switch buck boost converter,

#include "F28x_Project.h"
//
// Defines
//
//definitions for selecting DACH reference
#define REFERENCE_VDDA     0
#define REFERENCE_VDAC     1
//definitions for COMPH input selection
#define NEGIN_DAC          0
#define NEGIN_PIN          1
//definitions for CTRIPH/CTRIPOUTH output selection
#define CTRIP_ASYNCH       0
#define CTRIP_SYNCH        1
#define CTRIP_FILTER       2
#define CTRIP_LATCH        3
//definitions for selecting output pin
#define GPIO_CTRIP_PIN_NUM      14 //OUTPUTXBAR3 is mux'd with GPIO14
#define GPIO_CTRIP_PER_NUM       6 //OUTPUTXBAR3 is peripheral option 6 for
                                   //GPIO14
#define GPIO_CTRIPOUT_PIN_NUM   1 //EPwm1B is mux'd with GPIO15
#define GPIO_CTRIPOUT_PER_NUM    1 //EPwm1B is peripheral option 1 for GPIO15
//
// Function Prototypes
//
void InitCMPSS(void);
void InitEPWM(void);
//
// Main
//
void main(void)
{
//
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the F2837xD_SysCtrl.c file.
//
    InitSysCtrl();
//
// Step 2. Initialize GPIO:
// This example function is found in the F2837xD_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
//
    InitGpio();
//
// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
//
    DINT;
//
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the F2837xD_PieCtrl.c file.
//
    InitPieCtrl();
//
// Disable CPU interrupts and clear all CPU interrupt flags:
//
    IER = 0x0000;
    IFR = 0x0000;
//
// Configure Comparator COMP1H to accept POS input from pin and NEG input
// from DAC
//
    InitCMPSS();
//
// Configure COMP1 to feed TRIP4 EPWM DC trip input
//
    InitEPWM();
//
// Configure GPIO14 to output CTRIP1H/EPWM TRIP4
//
    GPIO_SetupPinMux(GPIO_CTRIP_PIN_NUM, GPIO_MUX_CPU1, GPIO_CTRIP_PER_NUM);
//
// Configure GPIO15 to output CTRIPOUT1H
//
    GPIO_SetupPinMux(GPIO_CTRIPOUT_PIN_NUM, GPIO_MUX_CPU1,
                     GPIO_CTRIPOUT_PER_NUM);
    while(1)
    {
        //
        // Trip flags set when CTRIP signal is asserted
        //
        if( EPwm1Regs.TZFLG.bit.OST )
        {
            EALLOW;
            //
            // Wait for comparator CTRIP to de-assert
            //
            while( Cmpss1Regs.COMPSTS.bit.COMPHSTS );
            //
            // Clear trip flags
            //
            EPwm1Regs.TZCLR.bit.OST = 1;
            EPwm1Regs.TZCLR.bit.INT = 1;
            EDIS;
        }
    }
}
//
// InitCMPSS - Initialize CMPSS1 and configure settings
//
void InitCMPSS(void)
{
    EALLOW;
    //
    //Enable CMPSS
    //
    Cmpss1Regs.COMPCTL.bit.COMPDACE = 1;
    //
    //NEG signal comes from DAC
    //
    Cmpss1Regs.COMPCTL.bit.COMPHSOURCE = NEGIN_DAC;
    //
    //Use VDDA as the reference for DAC
    //
    Cmpss1Regs.COMPDACCTL.bit.SELREF = REFERENCE_VDDA;
    //
    //Set DAC to midpoint for arbitrary reference
    //
    Cmpss1Regs.DACHVALS.bit.DACVAL = 2500;
    //
    // Configure CTRIPOUT path
    // Asynch output feeds CTRIPH and CTRIPOUTH
    //
    Cmpss1Regs.COMPCTL.bit.CTRIPHSEL = CTRIP_SYNCH;
    Cmpss1Regs.COMPCTL.bit.CTRIPOUTHSEL = CTRIP_SYNCH;
    //
    // Configure CTRIPOUTH output pin
    // Configure OUTPUTXBAR3 to be CTRIPOUT1H
    //
    OutputXbarRegs.OUTPUT3MUX0TO15CFG.bit.MUX0 = 0;
    //
    //Enable OUTPUTXBAR3 Mux for Output
    //
    OutputXbarRegs.OUTPUT3MUXENABLE.bit.MUX0 = 1;
    EDIS;
}
//
// InitEPWM - Initialize EPwm1 module settings
//
void InitEPWM(void)
{
    EALLOW;
    // CpuSysRegs.PCLKCR2.bit.EPWM1=1;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    //
    //Configure EPWM to run at SYSCLK
    //
    ClkCfgRegs.PERCLKDIVSEL.bit.EPWMCLKDIV = 0;
    EPwm1Regs.TBCTL.bit.CLKDIV = 1;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = 1;
    //
    //Initialize dummy values for EPWM CTR/PRD
    //
    EPwm1Regs.TBCTR = 100;
    EPwm1Regs.TBPRD = 3000;
    //
    //Configure EPwm1B to output high on TZB TRIP
    //
    EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_HI;
    //
    //Configure DCB to be TRIP4
    //
    EPwm1Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_HI;
    EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0xF;
    EPwm1Regs.DCBHTRIPSEL.bit.TRIPINPUT4 = 1;
    //
    //Configure DCB as OST
    //
    EPwm1Regs.TZSEL.bit.DCBEVT1 = 1;
    //
    //Configure DCB path to be unfiltered & async
    //
    EPwm1Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT1;
    EPwm1Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    //
    //Configure TRIP4 to be CTRIP1H
    //
    EPwmXbarRegs.TRIP4MUX0TO15CFG.bit.MUX0 = 0;
    //
    //Enable TRIP4 Mux for Output
    //
    EPwmXbarRegs.TRIP4MUXENABLE.bit.MUX0 = 1;
    //
    // Clear trip flags
    //
    EPwm1Regs.TZCLR.bit.OST = 1;
    EPwm1Regs.TZCLR.bit.INT = 1;
    //
    //Enable DCB interrupt
    //
    EPwm1Regs.TZEINT.bit.OST = 1;
    //
    // Enable PWM
    //
    EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
    EDIS;
}
The output of pwm is gets high when peak value is reached ,
but I want the  pwm to go low at this condition. also What to do for  generating 4 pwm from this code
  • Hello,

    To clarify, do you want the PWM outputs to go high when tripped? This can be done by configuring the TZA and TZB bits (to configure the outputs of EPWMxA and EPWMxB when a trip condition is met). You can configure both channels to go low upon a trip condition.

    To configure this for several PWM modules, you just need to apply the same initializations for each EPWM module (e.g. EPWM1, EPWM2, etc). Please refer to the below resources to learn about how our EPWM works and how to configure them. We have several intro to EPWM videos/documentation/examples to refer to:

    Best Regards,

    Allison

  • hi ,i have resolved the pwm issue but this sample code is working in the one shot trip whenever i try to change it into cycle by cycle operation pwms are not triggered by the trip signal

  • Hello,

    Glad to hear you have it working. What is the trip condition? Is the condition cleared on the next PWM cycle? Or is the condition always present? Can you please check the CBC flags to see if they are getting cleared when the condition is no longer present?

    Best Regards,

    Allison