void TIM_PrescalerConfig(TIM_TypeDef* TIMx, u16 Prescaler, u16 TIM_PSCReloadMode) { /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_PRESCALER_RELOAD(TIM_PSCReloadMode)); /* Set the Prescaler value */ TIMx->PSC = Prescaler; /* Set or reset the UG Bit */ TIMx->EGR = TIM_PSCReloadMode; }
I solved the problem :-] using a function to devide the tim clock, for 655535. Now the frequency step is around 0.016Hz. I'm able to measure the 40 Hz.
TIM_PrescalerConfig(TIM2, 0x1987, TIM_PSCReloadMode_Immediate); TIM2_IRQHandler: /* Clear TIM2 Capture compare interrupt pending bit */ TIM_ClearITPendingBit(TIM2, TIM_IT_CC2); /* Get the Input Capture value */ IC2Value = TIM_GetCapture2(TIM2); velmotor = (11017.5975/ IC2Value);
On 26-05-2009 at 07:06, Anonymous wrote: Did you see function you've used? void TIM_PrescalerConfig(TIM_TypeDef* TIMx, u16 Prescaler, u16 TIM_PSCReloadMode) { /* Check the parameters */ assert_param(IS_TIM_ALL_PERIPH(TIMx)); assert_param(IS_TIM_PRESCALER_RELOAD(TIM_PSCReloadMode)); /* Set the Prescaler value */ TIMx->PSC = Prescaler; /* Set or reset the UG Bit */ TIMx->EGR = TIM_PSCReloadMode; } You are write. I had mistake PSC for IC1PS. The correct is change the PSC and not the IC prescaler. Thanks