2025-07-05 9:37 AM
I'm getting unexpected signal in PWM output on timer1 channels.
Signal screenshots are attached.
getting unexpected signal (around 500nS) in between PWM duty cycle pulse.
Below is timer configuration : NOTE*: CCR values changes with software as required to generate desire waveform.
static void MX_TIM1_Init(void)
{
/* USER CODE BEGIN TIM1_Init 0 */
/* USER CODE END TIM1_Init 0 */
TIM_ClearInputConfigTypeDef sClearInputConfig = {0};
TIM_MasterConfigTypeDef sMasterConfig = {0};
TIM_OC_InitTypeDef sConfigOC = {0};
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
/* USER CODE BEGIN TIM1_Init 1 */
/* USER CODE END TIM1_Init 1 */
htim1.Instance = TIM1;
htim1.Init.Prescaler = 0;
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
htim1.Init.Period = 8400;
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
{
Error_Handler();
}
sClearInputConfig.ClearInputState = ENABLE;
sClearInputConfig.ClearInputSource = TIM_CLEARINPUTSOURCE_COMP6;
if (HAL_TIM_ConfigOCrefClear(&htim1, &sClearInputConfig, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM2;
sConfigOC.Pulse = 5400;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.OCPolarity = TIM_OCPOLARITY_LOW;
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
{
Error_Handler();
}
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
{
Error_Handler();
}
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
sBreakDeadTimeConfig.DeadTime = 0;
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
sBreakDeadTimeConfig.BreakFilter = 0;
sBreakDeadTimeConfig.BreakAFMode = TIM_BREAK_AFMODE_INPUT;
sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
sBreakDeadTimeConfig.Break2Filter = 0;
sBreakDeadTimeConfig.Break2AFMode = TIM_BREAK_AFMODE_INPUT;
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
{
Error_Handler();
}
2025-07-05 10:12 AM
What is the full chip number?
What is unexpected about the signal?
What is the signal hooked up to? Significantly slower rising edge than falling, why?
What is COMP6 doing here?
2025-07-05 8:36 PM
STM32G474RBT6
when PWM turn on period is running signal goes down for 500nS and same thing happen when PWM is in low state.
this signal is measure from IGBT gate , gate capacitance make rising slower. but signal is coming from MCU i check it on MCU pins.
COM6 is used for clear input source in event of overcurrent.
Look at video for better understanding.
2025-07-06 5:53 AM
If you disable the ClearInputState functionality, does the spike go away? Doesn't seem like overcurrent would only trip for 500 ns, but it's worth checking. Might be a spike on that line due to cross-talk. That's my guess.
If you disconnect the load, if possible, does this spike go away? Could the code be changing CCR temporarily for 500 ns?
2025-07-06 6:04 AM
ClearInputState is only enable for Channel 1 .
We are getting this issue on Channel 2 and Channel 3 .
it remains same if we disable ClearInput.
main issue is that this 500nS pulse comes between duty cycle which is not possible when a output cycle start, any change is effective only in next cycle.
2025-07-06 6:36 AM
Yep, I'm out of ideas. My guess is if you replicated these settings on a nucleo board you would not see the spike, so consider what is different between your setup and that.
Please post if you figure it out.
2025-07-06 6:38 AM
okk okk thanks for guidance , thats good idea i might be wrong with circuit.