STM32 TIM input captures bilateral edge detection Tim_icpolarity_bothedge
Come directly, first on the code:
Initialize TIM1 input capture parameter
Tim1_icinitstructure.tim_channel = tim_channel_1;//cc1s=01 Select input IC1 map to TI1 tim1_
icinitstructure.tim_icpolarity = Tim_icpolarity_bothedge;
Tim1_icinitstructure.tim_icselection = Tim_icselection_directti; Map to TI1 on
tim1_icinitstructure.tim_icprescaler = TIM_ICPSC_DIV1; Configuration input divider, non-crossover
tim1_icinitstructure.tim_icfilter = 0x00;//ic1f=0000 configuration input filter not filtered
tim_icinit (TIM1, &tim1_ Icinitstructure);
First of all, this code is not realized in the bilateral input capture, the specific reason is that St this piece did not do well, Tim_icpolarity_bothedge no use
Thanks to the great God in this post, the problem is solved.
Http://www.openedv.com/thread-12644-1-1.html
As described in the post, the code:
/********************* enable bilateral edge detection ************************/
//http://www.openedv.com/thread-12644-1-1.html
Tim1->ccer &= (uint16_t) ~ ((uint16_t) tim_ccer_cc1e);
TIM1->CCMR1 |= 0x03;
TIM1->SMCR |= (1 << 6);
TIM1->SMCR &= ~ ((1 << 5) | (1 << 4));
Tim1->ccer |= ((uint16_t) tim_ccer_cc1e);
/********************* enable bilateral edge detection ************************/