cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in STM32L1xx_StdPeriph_Lib_V1.3.1 - function TIM_SetIC2Prescaler()

viniciusfre
Associate II
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
2 REPLIES 2
Walid FTITI_O
Senior II
Posted on June 14, 2016 at 10:35

Hi maciel.vinicius, 

Thanks for the feedback. I report it internally.

-Hannibal-

viniciusfre
Associate II
Posted on June 14, 2016 at 13:18

Hi Hannibal,

Actually I made a mistake, sorry. :( The function is correct.