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.

CCS/TMS320F28069M: Creation three pwm signals .

Part Number: TMS320F28069M
Other Parts Discussed in Thread: CONTROLSUITE,

Tool/software: Code Composer Studio


Hello everyone! I am beginner in this work with microconrollers and I really need your help. I have some problem with microconroller TMS320 980 F28069MPZT CB-6CA77TM on the TAPAS board.

The Goal:
Right now my purpose is created three pwm signals with some dead-time and phase shift. I use RAM memory for initialization of the program.

The Problem:
Then only one signal is created it works fine if:

EPwm4Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active high complementary
or
EPwm4Regs.DBCTL.bit.POLSEL = DB_ACTV_LOW; // Active low complementary

However, if I use (EPwm4Regs.DBCTL.bit.POLSEL = DB_ACTV_HI;) or if I don't even use the POLSEL command then the loop stops in the main after couple of thousand of times

If the "pause" button would be clicked during the stuck, then the error appears: "Break at address "0x3ff671" with no debug information available, or outside of program code."

If I add at least one pwm with phase shift then the same error appears again. Even if, I don't use dead-time at all.

The Question:

I think it is problem with memory, but I can not say that is exact problem. Maybe do you have some thoughts about it?

The Remark:

In future, I will add an interrupt method to create a sinusoidal pwm signal, but it takes much hugher memory. I tried to use at least for one pwm but it works for couple seconds ( I see the correct curve in oscilloscope) and then the same error is appeared.

Thank you for attention!


The Code:

#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
#include "IQmathLib.h"
#include "math.h"

void InitEPwmTimer(void);

// Global variables used in this example
Uint16 PRD = 2252; //PWM Period 2252
int loop_count = 0;
int int_count = 0;


void main()
{


// Step 1. Initialize System Control:
InitSysCtrl();

// Step 2. Initialize GPIO:
InitGpio();
InitEPwmGpio();

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
DINT;

// Initialize the PIE control registers to their default state.
InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
InitPieVectTable();

// Step 4. Initialize all the Device Peripherals:
InitEPwmTimer(); // For this example, only initialize the ePWM Timer

// Initialize counters:
// Enable CPU INT3 which is connected to EPWM1-6 INT:
IER |= M_INT3;

// Enable EPWM INTn in the PIE: Group 3 interrupt 1-6
PieCtrlRegs.PIEIER3.bit.INTx4 = 1;

// Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM

// Step 6. IDLE loop. Just sit and loop forever (optional):
while(1){
loop_count++;
}

} // End main

void InitEPwmTimer()
{

EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Stop all the TB clocks
EDIS;

// Enable Sync

EPwm4Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Pass through
EPwm4Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm4Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm4Regs.TBCTL.bit.FREE_SOFT = 0; // Initially disable Free/Soft
EPwm4Regs.TBPRD = PRD-1; // Set up PWM1 Period
EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up mode
EPwm4Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm4Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm4Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 1st event
EPwm4Regs.TBCTR = 0x0000; // Clear timer counter
EPwm4Regs.CMPA.half.CMPA = PRD/2; //CompareA event at half of PRD
EPwm4Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero
EPwm4Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Master module
EPwm4Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm4Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm4Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm4Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm4Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm4Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on event A, up count
EPwm4Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM1A on event A, down count
EPwm4Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set PWM1B on event B, up count
EPwm4Regs.AQCTLB.bit.CAD = AQ_SET; // Clear PWM1B on event B, down
//Dead-base
EPwm4Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module
EPwm4Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active high complementary
EPwm4Regs.DBRED = 15;
EPwm4Regs.DBFED = 15;

// ePWM2
EPwm5Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Pass through
EPwm5Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm5Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm5Regs.TBCTL.bit.FREE_SOFT = 0; // Initially disable Free/Soft Bits
EPwm5Regs.TBPRD = PRD-1; // Set up PWM1 Period
EPwm5Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up mode
EPwm5Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm5Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm5Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 1st event
EPwm5Regs.TBCTR = 0x0000; // Clear timer counter
EPwm5Regs.CMPA.half.CMPA = PRD/2; //CompareA event at half of period
EPwm5Regs.TBPHS.half.TBPHS = 750; // Set Phase register to zero
EPwm5Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Slave module
EPwm5Regs.TBCTL.bit.PRDLD = TB_SHADOW;
EPwm5Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm5Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm5Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm5Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm5Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on event A, up count
EPwm5Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM1A on event A, down count
EPwm5Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Set PWM1B on event B, up count
EPwm5Regs.AQCTLB.bit.CAD = AQ_SET; // Clear PWM1B on event B, down
//Dead-base
EPwm5Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module
EPwm5Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active high complementary
EPwm5Regs.DBRED = 15;
EPwm5Regs.DBFED = 15;

// The EPwm6 is the same like EPwm5 but with different PHSEN

EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Start all the timers synced
EDIS;
}



  • This problem is probably not directly a PWM issue. I think your program is running off in to uninitialized memory.

    Do you have any interrupts configured? If so one of them may be causing this.

    Has your PIE vector table been correctly configured? If not an interrupt may cause undesirable results.

    Regards,
    Cody
  • Thank you for the answer, Cody Watkins.

    I have interrupt method in the full version of the program. But if I comment all codes which consist an interrupt method then error does not go away. So interrupt is not the reason of the error I think. 

    PIE vector table can be the reason of the problem. I filled in my project from controlSUITE/device_support/f2806x/v151 and took all required files from this folder and did not change the source files (include F2806x_PieVect.c. and F2806x_PieCtrl.c). Below I attach the photo of my "source" folder, maybe it would be helpful to understand which files the project has. 

    Maybe do you know some possibilities to check the problems with "InitPieVectTable();" method? How should I check that my PIE vector table been correctly configured?

    Best regards, Arsenii Ostapenko.

  • Update:

    I try to run the program in another device (C2000 LaunchPadXL TMS320F28069M) with the identical microcontroller. The meander was build correctly with any configurations (include the ex-problem code with POLSEL and PHASE).

    Then I try the full version with interrupt and sinusoidal CMPA and it works fine too (the correct code below).

    Therefore the problem is definitely with first board (SDI TAPAS). I hope this information would be helpful. Do have some ideas?

    Code:

    #include "DSP28x_Project.h" // Device Headerfile and Examples Include File
    #include "IQmathLib.h"
    #include "math.h"


    // Variables
    float t = 0; // Zeit
    float A = 0; // Amplitude (initial value)
    char f = 0; // frequency (initial value)
    char count = 0; // Counter for rising signal
    float U_stell=0; // Voltage
    Uint16 PRD = 2250; //PWM Period 2252
    int16 MfuncC1 = 0x4000; // Input: EPWM1 A&B Duty cycle ratio (Q15)
    int16 PWM1out = 0x4000;


    // Methods
    __interrupt void epwm_timer_isr(void);
    void InitEPwmTimer(void);

    int main(void)
    {

    // Step 1. Initialize System Control:
    InitSysCtrl();

    // Step 2. Initialize GPIO:
    InitGpio(); // Skipped for this example - LEDs set up in main code
    InitEPwmGpio();

    // Step 3. Clear all interrupts and initialize PIE vector table:
    DINT;

    // Initialize 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 F2806x_PieCtrl.c file.
    InitPieCtrl();

    // Disable CPU interrupts and clear all CPU interrupt flags:
    IER = 0x0000;
    IFR = 0x0000;

    // Initialize the PIE vector table with pointers to the shell Interrupt
    InitPieVectTable();

    EALLOW; // This is needed to write to EALLOW protected registers
    PieVectTable.EPWM4_INT = &epwm_timer_isr;
    EDIS; // This is needed to disable write to EALLOW protected registers

    InitEPwmTimer();

    // Initialize counters:
    // Enable CPU INT3 which is connected to EPWM1-6 INT:
    IER |= M_INT3;

    // Enable EPWM INTn in the PIE
    PieCtrlRegs.PIEIER3.bit.INTx4 = 1;

    // Enable global Interrupts and higher priority real-time debug events:
    EINT; // Enable Global interrupt INTM
    ERTM; // Enable Global realtime interrupt DBGM


    while(1){
    }
    }

    void InitEPwmTimer()
    {
    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    EPwm4Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Pass through
    EPwm4Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
    EPwm4Regs.TBCTL.bit.CLKDIV = TB_DIV1;
    EPwm4Regs.TBCTL.bit.FREE_SOFT = 0; // Initially disable Free/Soft Bits
    EPwm4Regs.TBPRD = PRD-1; // Set up Period
    EPwm4Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up mode
    EPwm4Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
    EPwm4Regs.ETSEL.bit.INTEN = 1; // Enable INT
    EPwm4Regs.ETPS.bit.INTPRD = ET_1ST; // Generate INT on 1st event
    EPwm4Regs.TBCTR = 0x0000; // Clear timer counter
    EPwm4Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero
    EPwm4Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Master module
    EPwm4Regs.TBCTL.bit.PRDLD = TB_SHADOW;
    EPwm4Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
    EPwm4Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
    EPwm4Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
    EPwm4Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero
    EPwm4Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on event A, up count
    EPwm4Regs.AQCTLA.bit.CAD = AQ_CLEAR; // Clear PWM1A on event A, down count
    EPwm4Regs.AQCTLB.bit.CAU = AQ_CLEAR; // Clear PWM1B on event B, up count
    EPwm4Regs.AQCTLB.bit.CAD = AQ_SET; // Set PWM1B on event B, down
    //Dead-base
    EPwm4Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable Dead-band module
    EPwm4Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active Hi complementary
    EPwm4Regs.DBRED = 15;
    EPwm4Regs.DBFED = 15;

    EALLOW;
    SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;
    }

    // Interrupt routines uses in this example:
    __interrupt void epwm_timer_isr(void)
    {

    // Changing of time
    t = t+0.00005;
    if(t>= 2000){t=t-2000;}

    // Smooth rising of signal
    count++;
    if (count == 100 && f < 101){
    A = A + 0.01;
    f++;
    count = 0;
    }

    // Define sinusoidal voltage
    U_stell=A*sin(f*t*2*3.14159265358979323846);

    // IQ math calculation
    MfuncC1 =(int)((float)((U_stell*0.5)*1000+500));
    PWM1out=((int32)PRD*(int32)MfuncC1)/1000;

    // Define CMPA with new sinusoidal value
    EPwm4Regs.CMPA.half.CMPA=PWM1out;


    PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
    EPwm4Regs.ETCLR.bit.INT=1;

    }

  • Sorry, i'm not familiar, what is this "TAPAS board"?

    What is the clock source? Can you confirm that you are clocking the device at the correct speed?

    If you code runs correctly on the LaunchPad, then its probably something HW related, but do note your SW could still have a bug if the HW connections are different between the boards.

    I would still recommend you check your interrupts, maybe you could disable INTM and see if you code still has the issue. That would rule out all maskable interrupts.\

    Regards,
    Cody 

  • Are you still having issues with this?

    Thanks,
    Cody
  • I am closing this due to inactivity.