Part Number: TMS320F28379D
Tool/software:
Hello Experts,
Looking at the EPWM_setCounterCompareShadowLoadMode() function in epwm.h, part of the driverlib package, this function does not enable shadow load mode?
I think it is hardwired to only use Immediate mode only?
Is this a bug in the epwm driver , could you please check this.
Here is the function:
//*****************************************************************************
//
//! Sets up the Counter Compare shadow load mode
//!
//! \param base is the base address of the EPWM module.
//! \param compModule is the counter compare module.
//! \param loadMode is the shadow to active load mode.
//!
//! This function enables and sets up the counter compare shadow load mode.
//! Valid values for the variables are:
//! - compModule
//! - EPWM_COUNTER_COMPARE_A - counter compare A.
//! - EPWM_COUNTER_COMPARE_B - counter compare B.
//! - EPWM_COUNTER_COMPARE_C - counter compare C.
//! - EPWM_COUNTER_COMPARE_D - counter compare D.
//! - loadMode
//! - EPWM_COMP_LOAD_ON_CNTR_ZERO - load when counter equals zero
//! - EPWM_COMP_LOAD_ON_CNTR_PERIOD - load when counter equals period
//! - EPWM_COMP_LOAD_ON_CNTR_ZERO_PERIOD - load when counter equals
//! zero or period
//! - EPWM_COMP_LOAD_FREEZE - Freeze shadow to active load
//! - EPWM_COMP_LOAD_ON_SYNC_CNTR_ZERO - load when counter equals zero
//! - EPWM_COMP_LOAD_ON_SYNC_CNTR_PERIOD -load when counter equals period
//! - EPWM_COMP_LOAD_ON_SYNC_CNTR_ZERO_PERIOD - load when counter equals
//! zero or period
//! - EPWM_COMP_LOAD_ON_SYNC_ONLY - load on sync only
//!
//! \return None.
//
//*****************************************************************************
static inline void
EPWM_setCounterCompareShadowLoadMode(uint32_t base,
EPWM_CounterCompareModule compModule,
EPWM_CounterCompareLoadMode loadMode)
{
uint16_t syncModeOffset;
uint16_t loadModeOffset;
uint16_t shadowModeOffset;
uint32_t registerOffset;
//
// Check the arguments
//
ASSERT(EPWM_isBaseValid(base));
if((compModule == EPWM_COUNTER_COMPARE_A) ||
(compModule == EPWM_COUNTER_COMPARE_C))
{
syncModeOffset = 10U;
loadModeOffset = 0U;
shadowModeOffset = 4U;
}
else
{
syncModeOffset = 12U;
loadModeOffset = 2U;
shadowModeOffset = 6U;
}
//
// Get the register offset. EPWM_O_CMPCTL for A&B or
// EPWM_O_CMPCTL2 for C&D
//
registerOffset = base + EPWM_O_CMPCTL + ((uint32_t)compModule & 0x1U);
//
// Set the appropriate sync and load mode bits and also enable shadow
// load mode. Shadow to active load can also be frozen.
//
HWREGH(registerOffset) = ((HWREGH(registerOffset) &
~((0x3U << syncModeOffset) | // Clear sync mode
(0x3U << loadModeOffset) | // Clear load mode
(0x1U << shadowModeOffset))) | // shadow mode
((((uint16_t)loadMode >> 2U) << syncModeOffset) |
(((uint16_t)loadMode & 0x3U) << loadModeOffset)));
}
I tried using it like this:
EPWM_setCounterCompareShadowLoadMode(EPWM3_BASE,
EPWM_COUNTER_COMPARE_A,
EPWM_COMP_LOAD_ON_CNTR_ZERO);
But the CMPCTL(SHDWAMODE bit) is still 1, i.e Immediate load mode!!

As per the TRM manual if SHDWAMODE is 1 , it is still in Immediate load mode!

