STM32 TIM input captures bilateral edge detection tim_icpolarity_bothedge

Source: Internet
Author: User
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 ************************/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.