cancel
Showing results for 
Search instead for 
Did you mean: 

changing TIM1 Dead-time generator setup continuously

alireza
Associate

HI,

I want to change tim1 Dead-time generator setup continuously between 10 -120

first time I set Dead-time with cube mx and it worked correctly

  sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
  sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
  sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
  sBreakDeadTimeConfig.DeadTime = 10;
  sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
  sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
  sBreakDeadTimeConfig.BreakFilter = 0;
  sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
  sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
  sBreakDeadTimeConfig.Break2Filter = 0;
  sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
  if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK)
  {
    Error_Handler();
  }

then i wrote a function to change that with variable

void user_deadtime(uint8_t value)
{
	TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
	sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
	sBreakDeadTimeConfig.OffStateIDLEMode = TIM_OSSI_DISABLE;
	sBreakDeadTimeConfig.LockLevel = TIM_LOCKLEVEL_OFF;
	sBreakDeadTimeConfig.DeadTime = value;
	sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
	sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
	sBreakDeadTimeConfig.BreakFilter = 0;
	sBreakDeadTimeConfig.Break2State = TIM_BREAK2_DISABLE;
	sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
	sBreakDeadTimeConfig.Break2Filter = 0;
	sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
	if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK)
	{
		Error_Handler();
	}
 
}

it didnt work , after first change ,pwm will be stop

i try to that with registers

void user_deadtime(uint8_t value)
{
 
	uint32_t temp;
	temp=TIM1->BDTR;
	TIM1->BDTR=temp|value;
 
}

and i got same result . after first change , pwm will be stop

i debug it and i understood that when i set TIM1->BDTR the value will not change , and it got wrong value that i never set that.

how can i set that after continuously ?

i am using stm32f746

thanks

2 REPLIES 2

> i debug it and i understood that when i set TIM1->BDTR the value will not change

Why do you think so?

> and it got wrong value that i never set that.

 What value?

What is content of BDTR before and after calling given function? Is BDTR.MOE set? What is content of other TIM registers when PWM stops to work?

JW

Piranha
Chief II
TIM1->BDTR=temp|value;

It doesn't do what you think it does. This is why a basic programming must be learned first...