Skip to main content
viniciusfre
Associate II
June 13, 2016
Question

Bug in STM32L1xx_StdPeriph_Lib_V1.3.1 - function TIM_SetIC2Prescaler()

  • June 13, 2016
  • 2 replies
  • 771 views
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
This topic has been closed for replies.

2 replies

Walid FTITI_O
Visitor II
June 14, 2016
Posted on June 14, 2016 at 10:35

Hi maciel.vinicius, 

Thanks for the feedback. I report it internally.

-Hannibal-

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

Hi Hannibal,

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