AnsweredAssumed Answered

Bug in STM32L1xx_StdPeriph_Lib_V1.3.1 - function TIM_SetIC2Prescaler()

Question asked by maciel.vinicius on Jun 13, 2016
Latest reply on Jun 14, 2016 by maciel.vinicius
Hi,
I have found a bug inside function TIM_SetIC2Prescaler() from STM32L1xx_StdPeriph_Lib_V1.3.1, which is the latest version. The current code is:
void TIM_SetIC2Prescaler(TIM_TypeDef* TIMx, uint16_t TIM_ICPSC)
{
  /* Check the parameters */
  assert_param(IS_TIM_LIST2_PERIPH(TIMx));
  assert_param(IS_TIM_IC_PRESCALER(TIM_ICPSC));
   
  /* Reset the IC2PSC Bits */
  TIMx->CCMR1 &= (uint16_t)~((uint16_t)TIM_CCMR1_IC2PSC);
  /* Set the IC2PSC value */
  TIMx->CCMR1 |= (uint16_t)(TIM_ICPSC << 8);
}
The bit TIM_ICPSC should be shift by 10, not 8!
TIMx->CCMR1 |= (uint16_t)(TIM_ICPSC << 10); // BUG: IC2PSC is Bits 11:10, not bit 8

Outcomes