Question
Bug in STM32L1xx_StdPeriph_Lib_V1.3.1 - function TIM_SetIC2Prescaler()
Posted on June 13, 2016 at 16:33
Hi,
I have found a bug inside functionTIM_SetIC2Prescaler() fromSTM32L1xx_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
#stm32l151