PWM APP, method for phase shifting / setting initial timer value

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User13960
Level 3
Level 3
First like received
Greetings all,

I have 3 x PWM APP's all running the same duty and period.

I would like to phase shift them such that the output pulses are spread equally over the period.

Is there a method for doing this ? I'm thinking I should be able to initialise the timer value of each PWM to different values before I start them. Something like PWM_SetTimerValue().


Any suggestions would be greatly appreciated.

PHAB
0 Likes
1 Reply
User13960
Level 3
Level 3
First like received
OK, so there is a bug in the XMC PWM hardware or library. You cannot set the CCUy TIMER value once the CCUy module has been initialised by "DAVE_Init()". You can't even manually write to the CCUy TIMER value using the debugger. This could be why the Infineon have not published a "SetTimerValue" method for the PWM App.

I reported this under e-ticket 28586855 some time ago and it has now been closed. I have raised a new e-ticket 303874228.

In the mean time there is a work-around. Before trying to set the CCUy TIMER value, set the CCUy "General Idle Disable" bits(s) then start the CCUy(s)

For example...

int main(void)
{
PWM_t* HandlePtr;
uint32_t TimerValue;

DAVE_STATUS_t status;

status = DAVE_Init(); /* Initialization of DAVE APPs */

HandlePtr = &PWM_DRV2;

// The following line clears the idle states and is a work around for a bug in the PWMSP002 App or hardware
CCU81->GIDLC |= CCU8_GIDLC_CS3I_Msk | CCU8_GIDLC_CS2I_Msk | CCU8_GIDLC_CS1I_Msk | CCU8_GIDLC_CS0I_Msk;

// Offset the PWM_DRV2 timer (phase shift)
XMC_CCU8_SLICE_SetTimerValue(HandlePtr->ccu8_slice_ptr, (uint16_t)10000);

PWM_Start(&PWM_DRV1);
PWM_Start(&PWM_DRV2);

while(1U)
{
}
}



I hope this helps someone (took me some time to figure out)
PHAB
0 Likes