reset timer to 0 before restarting it

This commit is contained in:
Wolfgang Hottgenroth 2016-11-10 10:34:04 +01:00
parent d1aba59a5b
commit b363fded5f

View File

@ -108,10 +108,12 @@ void inverterStart(uint8_t freqOut, direction_t direction) {
timerSupport[i].running = false; timerSupport[i].running = false;
HAL_GPIO_WritePin(timerSupport[i].bridgePolarityPort, timerSupport[i].bridgePolarityPin, GPIO_PIN_RESET); HAL_GPIO_WritePin(timerSupport[i].bridgePolarityPort, timerSupport[i].bridgePolarityPin, GPIO_PIN_RESET);
__HAL_TIM_SET_AUTORELOAD(timerSupport[i].handle, slotWidth); __HAL_TIM_SET_AUTORELOAD(timerSupport[i].handle, slotWidth);
__HAL_TIM_SET_COUNTER(timerSupport[i].handle, 0);
} }
timer1Cnt = 0; timer1Cnt = 0;
__HAL_TIM_SET_AUTORELOAD(&htim1, slotWidth); __HAL_TIM_SET_AUTORELOAD(&htim1, slotWidth);
__HAL_TIM_SET_COUNTER(&htim1, 0);
HAL_TIM_Base_Start_IT(&htim1); HAL_TIM_Base_Start_IT(&htim1);
__HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE); __HAL_TIM_ENABLE_IT(&htim1, TIM_IT_UPDATE);
} }