Other Parts Discussed in Thread: C2000WARE
Tool/software: Code Composer Studio
GLDCTL2 register implements a very interesting function in F28379 because, combined with the link function from EPWMXLINK register, it allows a simultaneous update of various registers from different EPWM units at once.
Functions EPWM_setGlobalLoadOneShotLatch(uint32_t base) and EPWM_forceGlobalLoadOneShotEvent(uint32_t base), from the Peripheral Driver Library (driverlib.lib) are supposed to deal with GLDCTL2 register.
However, GLDCTL2 register needs EALLOW to be updated, which is lacking in both functions. In fact, from epwm.h we find:
static inline void EPWM_setGlobalLoadOneShotLatch(uint32_t base)
{
ASSERT(EPWM_isBaseValid(base));
// Set a one shot Global shadow load pulse.
HWREGH(base + EPWM_O_GLDCTL2) |= EPWM_GLDCTL2_OSHTLD;
}
and
static inline void EPWM_forceGlobalLoadOneShotEvent(uint32_t base)
{
ASSERT(EPWM_isBaseValid(base));
// Force a Software Global shadow load pulse.
HWREGH(base + EPWM_O_GLDCTL2) |= EPWM_GLDCTL2_GFRCLD;
}
instead of:
static inline void EPWM_setGlobalLoadOneShotLatch(uint32_t base)
{
ASSERT(EPWM_isBaseValid(base));
// Set a one shot Global shadow load pulse.
EALLOW;
HWREGH(base + EPWM_O_GLDCTL2) |= EPWM_GLDCTL2_OSHTLD;
EDIS;
}
and
static inline void EPWM_forceGlobalLoadOneShotEvent(uint32_t base)
{
ASSERT(EPWM_isBaseValid(base));
// Force a Software Global shadow load pulse.
EALLOW;
HWREGH(base + EPWM_O_GLDCTL2) |= EPWM_GLDCTL2_GFRCLD;
EDIS;
}
which would be correct. I initially found this problem in C2000ware version 1.01 and I was forced to use:
__eallow();
EPwm6Regs.GLDCTL2.bit.GFRCLD = 1;
__edis();
instead of:
EPWM_forceGlobalLoadOneShotEvent(EPWM6_BASE);
with less clarity in the program. In fact, without EALLOW and EDIS both functions are useless.
Since C2000ware is in version 1.06 now, and the problem hasn’t been corrected, I decided to create this post, hoping for a solution in C2000ware version 1.07. I did lose some many days wondering why my system didn’t work, until I found out that EPWM_forceGlobalLoadOneShotEvent(), wasn’t doing what it was supposed to do. In any case, I think this post can eventually save other developers’ time trying to deal with GLDCTL2 register through the Peripheral Driver Library.