Skip to content

Commit 8396d9e

Browse files
committed
[HAL][TIM] Fix update flag (UIF) clearing in TIM_Base_SetConfig
1 parent 5339ee5 commit 8396d9e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

Src/stm32c0xx_hal_tim.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6956,8 +6956,6 @@ void TIM_Base_SetConfig(TIM_TypeDef *TIMx, const TIM_Base_InitTypeDef *Structure
69566956
/* Set the auto-reload preload */
69576957
MODIFY_REG(tmpcr1, TIM_CR1_ARPE, Structure->AutoReloadPreload);
69586958

6959-
TIMx->CR1 = tmpcr1;
6960-
69616959
/* Set the Autoreload value */
69626960
TIMx->ARR = (uint32_t)Structure->Period ;
69636961

@@ -6970,16 +6968,15 @@ void TIM_Base_SetConfig(TIM_TypeDef *TIMx, const TIM_Base_InitTypeDef *Structure
69706968
TIMx->RCR = Structure->RepetitionCounter;
69716969
}
69726970

6971+
/* Disable Update Event (UEV) with Update Generation (UG)
6972+
by changing Update Request Source (URS) to avoid Update flag (UIF) */
6973+
SET_BIT(TIMx->CR1, TIM_CR1_URS);
6974+
69736975
/* Generate an update event to reload the Prescaler
69746976
and the repetition counter (only for advanced timer) value immediately */
69756977
TIMx->EGR = TIM_EGR_UG;
69766978

6977-
/* Check if the update flag is set after the Update Generation, if so clear the UIF flag */
6978-
if (HAL_IS_BIT_SET(TIMx->SR, TIM_FLAG_UPDATE))
6979-
{
6980-
/* Clear the update flag */
6981-
CLEAR_BIT(TIMx->SR, TIM_FLAG_UPDATE);
6982-
}
6979+
TIMx->CR1 = tmpcr1;
69836980
}
69846981

69856982
/**

0 commit comments

Comments
 (0)