Other Parts Discussed in Thread: C2000WARE, SYSCONFIG
Hi,
I am trying to generate a single double-pulse signal for driving a MOSFET double pulse testing rig using the EPWM module. The goal is to achieve a waveform similar to what is shown in the following figure:
I believe this should be fairly easy to implement on the launchpad. However, as I am totally new to the development platform, I have been struggling with this for a while now.
The approach that I have taken relies on the EPWM Trip Zone and event trigger submodules. I am able to generate the desired waveform using the CMPA and CMPB counter compares using the SYSCFG file, as shown in the picture. I am using the Event-Trigger submodule to generate an interrupt after every cycle. I have GPIO1 configured as an INPUTXBAR source in the SYSCFG file (gpio configured as input : push-pull output/ pull-up enabled on input). The idea is that when the interrupt is generated, it is handled in the interrupt void where GPIO0 is toggled, tripping the one-shot TZ1 (through the XBAR) and forcing the EPWM output to a low state.
Here is what I have got done with the help of various c2000ware examples and the C2000 ePWM developer's guide as well as similar problems found on this forum:
#include "driverlib.h"
#include "device.h"
#include "board.h"
uint32_t epwm1IntCount;
__interrupt void DPhandler(void);
void main(void)
{
epwm1IntCount = 0U;
Device_init(); // Initialize device clock and peripherals
Device_initGPIO(); // Disable pin locks and enable internal pull-ups.
Interrupt_initModule(); // Initialize PIE and clear PIE registers. Disables CPU interrupts.
Interrupt_initVectorTable(); // Initialize the PIE vector table with pointers to the shell Interrupt service Routines (ISR).
Board_init();
SysCtl_disablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC); // Disable sync(Freeze clock to PWM as well)
EPWM_setSyncOutPulseMode(myEPWM1_BASE, EPWM_SYNC_OUT_PULSE_ON_COUNTER_ZERO); // ePWM1 SYNCO is generated on CTR=0
Interrupt_enable(INT_EPWM1);
EPWM_setInterruptEventCount(myEPWM1_BASE, 0U);
Interrupt_register(INT_EPWM1, &DPhandler);
EPWM_enableTripZoneInterrupt(myEPWM1_BASE, EPWM_TZ_INTERRUPT_OST);
SysCtl_enablePeripheral(SYSCTL_PERIPH_CLK_TBCLKSYNC); // Enable sync and clock to PWM
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
for(;;) // IDLE loop. Just sit and loop forever (optional):
{
asm (" NOP");
}
}
__interrupt void DPhandler(void)
{
epwm1IntCount++; // Interrupt count
GPIO_togglePin(myGPIO1); // trip TZ1
EPWM_clearOneShotTripZoneFlag(myEPWM1_BASE, EPWM_TZ_OST_FLAG_OST1);
EPWM_clearTripZoneFlag(myEPWM1_BASE, (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_CBC));
EPWM_clearTripZoneFlag(myEPWM1_BASE, (EPWM_TZ_INTERRUPT | EPWM_TZ_FLAG_OST));
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP2); // acknowledge interrupt to continue
}
With the current solution, a single 4.6us pulse is generated, even though I have the timer period as well as the CMPA and CMPB values configured so that pulse1 should be 10us and pulse2 4us, with 3us between them. Below are the .syscfg configurations of the EPWM module. The TBCTR is configured to count down from the initial counter value 100 after sync event to make sure that the action qualifier event "time base counter equals zero" is catched.
Is my approach even applicable? I would highly appreciate any help with this.
As explained, right now I have configured the EPWM, GPIO, and INPUTXBAR using the .syscfg file. How does the SYSCFG come in play, if I want to configure the epwm duty cycles in the .c code? Will the configurations made in the .syscfg be overwritten? This might be something that I will want to do in the future, if I want to control the pulse widths using parameters.
Thank you very much for your help.
Best regards,
Juhani



