STM32/STM32L4: Review of last commit -- Eliminate possible underflow
This commit is contained in:
parent
7903a8a46c
commit
e379491d13
@ -1300,8 +1300,8 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv,
|
||||
|
||||
timclk = priv->pclk / prescaler;
|
||||
|
||||
reload = timclk / info->frequency - 1;
|
||||
if (reload < 1)
|
||||
reload = timclk / info->frequency;
|
||||
if (reload < 2)
|
||||
{
|
||||
reload = 1;
|
||||
}
|
||||
@ -1309,6 +1309,10 @@ static int pwm_timer(FAR struct stm32_pwmtimer_s *priv,
|
||||
{
|
||||
reload = 65535;
|
||||
}
|
||||
else
|
||||
{
|
||||
reload--;
|
||||
}
|
||||
|
||||
pwminfo("TIM%u PCLK: %u frequency: %u TIMCLK: %u prescaler: %u reload: %u\n",
|
||||
priv->timid, priv->pclk, info->frequency, timclk, prescaler, reload);
|
||||
|
@ -841,8 +841,8 @@ static int stm32l4pwm_timer(FAR struct stm32l4_pwmtimer_s *priv,
|
||||
|
||||
timclk = priv->pclk / prescaler;
|
||||
|
||||
reload = timclk / info->frequency - 1;
|
||||
if (reload < 1)
|
||||
reload = timclk / info->frequency;
|
||||
if (reload < 2)
|
||||
{
|
||||
reload = 1;
|
||||
}
|
||||
@ -850,6 +850,10 @@ static int stm32l4pwm_timer(FAR struct stm32l4_pwmtimer_s *priv,
|
||||
{
|
||||
reload = 65535;
|
||||
}
|
||||
else
|
||||
{
|
||||
reload--;
|
||||
}
|
||||
|
||||
pwminfo("TIM%u PCLK: %u frequency: %u TIMCLK: %u prescaler: %u reload: %u\n",
|
||||
priv->timid, priv->pclk, info->frequency, timclk, prescaler, reload);
|
||||
|
Loading…
Reference in New Issue
Block a user