Other Parts Discussed in Thread: C2000WARE
Tool/software:
Hello,
The schematic below shows the control board I am using, which includes the TMS320F28377S. As you can see in the diagram, the board is designed to use EPWM6A and beyond.
Among the examples provided in TI's C2000Ware, the epwm_up_aq example only utilizes EPWM1 to EPWM3. To adapt this for my needs, I modified the epwm_up_aq_cpu01.c file to use only EPWM6A, as shown below. (However, I did not make any changes to other files such as F2837xS_Gpio.c or F2837xS_EPwm.c.)
=====================================================================================================================================================================
#include "F28x_Project.h"
#define EPWM6_TIMER_TBPRD 2000 // Period register
#define EPWM6_MAX_CMPA 950
#define EPWM6_MIN_CMPA 50
#define EPWM6_MAX_CMPB 1950
#define EPWM6_MIN_CMPB 1050
EPWM_INFO epwm6_info;
void InitEPwm6Example(void);
__interrupt void epwm6_isr(void);
void main(void)
{
InitSysCtrl();
CpuSysRegs.PCLKCR2.bit.EPWM6=1;
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.EPWM6_INT = &epwm6_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
EALLOW;
CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS;
IER |= M_INT3;
PieCtrlRegs.PIEIER6.bit.INTx6 = 1;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
for(;;)
{
asm (" NOP");
}
}
//
// epwm6_isr - EPWM6 ISR to update compare values
//
__interrupt void epwm6_isr(void)
{
//
// Update the CMPA and CMPB values
//
update_compare(&epwm6_info);
//
// Clear INT flag for this timer
//
EPwm6Regs.ETCLR.bit.INT = 1;
//
// Acknowledge this interrupt to receive more interrupts from group 3
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
//
// InitEPwm6Example - Initialize EPWM6 values
//
void InitEPwm6Example()
{
//
// Setup TBCLK
//
EPwm6Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Count up
EPwm6Regs.TBPRD = EPWM6_TIMER_TBPRD; // Set timer period
EPwm6Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm6Regs.TBPHS.bit.TBPHS = 0x0000; // Phase is 0
EPwm6Regs.TBCTR = 0x0000; // Clear counter
EPwm6Regs.TBCTL.bit.HSPCLKDIV = TB_DIV2; // Clock ratio to SYSCLKOUT
EPwm6Regs.TBCTL.bit.CLKDIV = TB_DIV2;
//
// Setup shadow register load on ZERO
//
EPwm6Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm6Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm6Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm6Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
//
// Set Compare values
//
EPwm6Regs.CMPA.bit.CMPA = EPWM6_MIN_CMPA; // Set compare A value
EPwm6Regs.CMPB.bit.CMPB = EPWM6_MIN_CMPB; // Set Compare B value
//
// Set actions
//
EPwm6Regs.AQCTLA.bit.ZRO = AQ_SET; // Set PWM6A on Zero
EPwm6Regs.AQCTLA.bit.CAU = AQ_CLEAR; // Clear PWM6A on event A,
// up count
EPwm6Regs.AQCTLB.bit.ZRO = AQ_SET; // Set PWM6B on Zero
EPwm6Regs.AQCTLB.bit.CBU = AQ_CLEAR; // Clear PWM6B on event B,
// up count
//
// Interrupt where we will change the Compare Values
//
EPwm6Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm6Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm6Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event
//
// Information this example uses to keep track
// of the direction the CMPA/CMPB values are
// moving, the min and max allowed values and
// a pointer to the correct ePWM registers
//
epwm6_info.EPwm_CMPA_Direction = EPWM_CMP_UP; // Start by increasing
// CMPA & CMPB
epwm6_info.EPwm_CMPB_Direction = EPWM_CMP_UP;
epwm6_info.EPwmTimerIntCount = 0; // Zero the interrupt counter
epwm6_info.EPwmRegHandle = &EPwm6Regs; // Set the pointer to the
// ePWM module
epwm6_info.EPwmMaxCMPA = EPWM6_MAX_CMPA; // Setup min/max
// CMPA/CMPB values
epwm6_info.EPwmMinCMPA = EPWM6_MIN_CMPA;
epwm6_info.EPwmMaxCMPB = EPWM6_MAX_CMPB;
epwm6_info.EPwmMinCMPB = EPWM6_MIN_CMPB;
}
//
// update_compare - Update the compare values for the specified EPWM
//
void update_compare(EPWM_INFO *epwm_info)
{
//
// Every 10'th interrupt, change the CMPA/CMPB values
//
if(epwm_info->EPwmTimerIntCount == 10)
{
epwm_info->EPwmTimerIntCount = 0;
//
// If we were increasing CMPA, check to see if
// we reached the max value. If not, increase CMPA
// else, change directions and decrease CMPA
//
if(epwm_info->EPwm_CMPA_Direction == EPWM_CMP_UP)
{
if(epwm_info->EPwmRegHandle->CMPA.bit.CMPA < epwm_info->EPwmMaxCMPA)
{
epwm_info->EPwmRegHandle->CMPA.bit.CMPA++;
}
else
{
epwm_info->EPwm_CMPA_Direction = EPWM_CMP_DOWN;
epwm_info->EPwmRegHandle->CMPA.bit.CMPA--;
}
}
//
// If we were decreasing CMPA, check to see if
// we reached the min value. If not, decrease CMPA
// else, change directions and increase CMPA
//
else
{
if(epwm_info->EPwmRegHandle->CMPA.bit.CMPA == epwm_info->EPwmMinCMPA)
{
epwm_info->EPwm_CMPA_Direction = EPWM_CMP_UP;
epwm_info->EPwmRegHandle->CMPA.bit.CMPA++;
}
else
{
epwm_info->EPwmRegHandle->CMPA.bit.CMPA--;
}
}
//
// If we were increasing CMPB, check to see if
// we reached the max value. If not, increase CMPB
// else, change directions and decrease CMPB
//
if(epwm_info->EPwm_CMPB_Direction == EPWM_CMP_UP)
{
if(epwm_info->EPwmRegHandle->CMPB.bit.CMPB < epwm_info->EPwmMaxCMPB)
{
epwm_info->EPwmRegHandle->CMPB.bit.CMPB++;
}
else
{
epwm_info->EPwm_CMPB_Direction = EPWM_CMP_DOWN;
epwm_info->EPwmRegHandle->CMPB.bit.CMPB--;
}
}
//
// If we were decreasing CMPB, check to see if
// we reached the min value. If not, decrease CMPB
// else, change directions and increase CMPB
//
else
{
if(epwm_info->EPwmRegHandle->CMPB.bit.CMPB ==
epwm_info->EPwmMinCMPB)
{
epwm_info->EPwm_CMPB_Direction = EPWM_CMP_UP;
epwm_info->EPwmRegHandle->CMPB.bit.CMPB++;
}
else
{
epwm_info->EPwmRegHandle->CMPB.bit.CMPB--;
}
}
}
else
{
epwm_info->EPwmTimerIntCount++;
}
return;
}
//
// End of file
//
======================================================================================================================================================================
Despite completing the debugging process based on the modified file, I am not seeing any output on PWM6A when checking with an oscilloscope.
Could you provide guidance on which files and specific code modifications are required to enable EPWM6A output?
I would greatly appreciate your advice.
Best regards,
Seungsoo Kim









