2011-09-27 03:04 AM
Is it possible to use the timer clock prescaler in input capture mode? I used some different values but
that doesn't seem to make a difference, the value in TIM2->CCR3 is the same every time.
2011-09-27 12:35 PM
Yes.
Look at the peripheral code examples that come with the library. Cheers, Hal2011-09-28 12:13 AM
In the StdPeriphLib InputCapture example only the input capture prescaler is used not the timer clock prescaler.
2011-09-28 12:48 PM
Show your code and describe the capture input signal.
Cheers, Hal2011-09-29 02:16 AM
CPU speed 60MHz
APB2 prescaler = 1 60MHzAPB1 prescaler = 2 30MHz -> timer 2 clock 60MHzvoid TIM2_init(void){ RCC->APB1ENR |= (1 << TIM2EN); TIM2->PSC = 5; TIM2->CCMR2 = ( (1 << CC3S_bfi) | (1 << CC4S_bfi) ); TIM2->CCER = TIM_CCER_CC3P | TIM_CCER_CC4P; // capture on falling edge TIM2->DIER = TIM_DIER_CC3IE | TIM_DIER_CC4IE; }TIM2->CR1 |= TIM_CR1_CEN;TIM2->CCER |= TIM_CCER_CC3E | TIM_CCER_CC4E; // enable capture while(!(TIM2->SR & TIM_SR_CC3IF)) { // wait for the first falling edge } TIM2->CNT = 0x00000000; // clear counter p_res->reper_ticks_adj = TIM2->CCR3; // clear flag while(!(TIM2->SR & TIM_SR_CC3IF)) { // wait for the second falling edge } p_res->reper_ticks_adj = TIM2->CCR3; printf(''%u \n'',p_res->reper_ticks_adj); ...........................................................................The input signal is square wave. The time between two falling edges is 0.6sFor example:TIM2->PSC = 1;CCR3: 36 000 000 TIM2->PSC = 5;CCR3: 36 000 000 It looks like the timer is always clocked @ 60MHz no mather what the prescaler value is.2011-09-30 07:53 AM
Problem solved, i wasn't setting the UG bit :)g