Bug / Undefine behaviour in the PWM_CCU8 / PWM_CCU8_Stop function

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
In case this helps someone else, I believe there is a bug / undefined behaviour in the PWM_CCU8 App....

https://www.infineonforums.com/threads/4616-Problem-with-PWM_CCU8


I am using the PWM_CCU8 App to drive two FET's connected to each end of the primary winding on a centre tapped transformer. The App is configured to generate two pulse trains 180° out of phase with each other as follows...

Channel 1 Direct Output
Output enable = TRUE
Passive State = Before Compare Match
Passive Level = Low (so the FET is OFF on powerup / reset)



Channel 1 Inverted Output
Output enable = TRUE
Passive State = After Compare Match
Passive Level = Low (so the FET is OFF on powerup / reset)



The App generates the two signals correctly when the PWM_CCU8_Start() function is called, however when the PWM_CCU8_Stop() function is called the Direct Output returns to it's Passive Level setting (LOW) as expected but the Inverted Output is set to the INVERSE of it's Passive Level setting (HIGH)

In my application this leaves one half of the centre tapped transformer permanently on with the resultant current overload.

I have not been able to resolve this with any App configuration settings so I have created a workaround using my own Stop and Start functions below.

I hope this helps others.

Best regards
PHAB




//----------------------------------------------------------------------------
// Workaround for bug / undefined behaviour in DAVE PWM_CCU8 APP which leaves Inverted Output pin high when APP is stopped
//
// Stops the PWM then configures the Inverted Output pin of Channel 1 so it is NOT under PWM_CCU8 control and forces pin low
//----------------------------------------------------------------------------
//
// Originator : Aaron Walsh 17 Jan 2020
//---------------------------------------------------------------------------
void My_PWM_CCU8_Stop(PWM_CCU8_t* handle_ptr)
{
// Call standard function to stop the PWM
PWM_CCU8_Stop(&OP_ULTRA_A_B);

// Disconnect PWM_CCU8 APP Channel 1, Output 1 (Inverted Output) from output pin
// Set Pin mode to XMC_GPIO_MODE_OUTPUT_PUSH_PULL instead of XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT3 (Alternative mode 3 means hardware controlled by PWM_CCU8 on this pin)
handle_ptr->config_ptr->gpio_ch1_out1_ptr->IOCR[handle_ptr->config_ptr->gpio_ch1_out1_pin >> 2U] &= ~(uint32_t)XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT3 << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)handle_ptr->config_ptr->gpio_ch1_out1_pin & 0x3U));
handle_ptr->config_ptr->gpio_ch1_out1_ptr->IOCR[handle_ptr->config_ptr->gpio_ch1_out1_pin >> 2U] |= (uint32_t)XMC_GPIO_MODE_OUTPUT_PUSH_PULL << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)handle_ptr->config_ptr->gpio_ch1_out1_pin & 0x3U));
}

//----------------------------------------------------------------------------
// Workaround for bug / undefined behaviour in DAVE PWM_CCU8 APP which leaves Inverted Output pin high when APP is stopped
//
// Configures the Inverted Output pin of Channel 1 so it IS under PWM_CCU8 control then starts PWM APP
//----------------------------------------------------------------------------
//
// Originator : Aaron Walsh 17 Jan 2020
//---------------------------------------------------------------------------
void My_PWM_CCU8_Start(PWM_CCU8_t* handle_ptr)
{
// Connect PWM_CCU8 APP Channel 1, Output 1 (Inverted Output) to output pin
handle_ptr->config_ptr->gpio_ch1_out1_ptr->IOCR[handle_ptr->config_ptr->gpio_ch1_out1_pin >> 2U] &= ~(uint32_t)XMC_GPIO_MODE_OUTPUT_PUSH_PULL << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)handle_ptr->config_ptr->gpio_ch1_out1_pin & 0x3U));
handle_ptr->config_ptr->gpio_ch1_out1_ptr->IOCR[handle_ptr->config_ptr->gpio_ch1_out1_pin >> 2U] |= (uint32_t)XMC_GPIO_MODE_OUTPUT_PUSH_PULL_ALT3 << ((uint32_t)PORT_IOCR_PC_Size * ((uint32_t)handle_ptr->config_ptr->gpio_ch1_out1_pin & 0x3U));

// Call standard function to start the PWM
PWM_CCU8_Start(&OP_ULTRA_A_B);
}
0 Likes
0 Replies