Part Number: TMS320F280041
Tool/software: TI C/C++ Compiler
I was going through C28x X-BAR driver, more specifically XBAR_setEPWMMuxConfig() function.
Here is the implementation from xbar.c found in F28004x Support Library v1.06.00.00:
//*****************************************************************************
//
// XBAR_setEPWMMuxConfig
//
//*****************************************************************************
void
XBAR_setEPWMMuxConfig(XBAR_TripNum trip, XBAR_EPWMMuxConfig muxConfig)
{
uint32_t shift;
uint16_t offset;
//
// If the configuration is for MUX16-31, we'll need an odd value to index
// into the config registers.
//
if(((uint32_t)muxConfig & 0x2000U) != 0U)
{
offset = ((uint16_t)trip << 1U) + 2U;
}
else
{
offset = (uint16_t)trip << 1U;
}
//
// Extract the shift from the input value.
//
shift = ((uint32_t)muxConfig >> 8U) & 0x7FU;
//
// Write the requested muxing value for this XBAR trip.
//
EALLOW;
HWREG(XBAR_EPWM_CFG_REG_BASE + offset) =
(HWREG(XBAR_EPWM_CFG_REG_BASE + offset) & ~((uint32_t)0x3U << shift)) |
(((uint32_t)muxConfig & 0x3U) << shift);
EDIS;
}
Should the "shift" variable in this function be calculated as:
shift = ((uint32_t)muxConfig >> 8U) & 0x0FU;
I may be wrong, but the original mask for shift (0x7FU) won't work for mux 16 to 31. Can someone please check this out?
Thank you!