Stm32f0xx_tim input capture (compute frequency) configuration detail procedure

Source: Internet
Author: User

Objective

The timer on STM32 is powerful, and it is estimated that not many people have studied all the functions of the STM32 timer (including me), just use some of the usual features, and later I will introduce more features about the STM32 timer.

STM32 chip Most of the 16-bit count, but basically there are 1 or two 32-bit timers, unfortunately, we most often use the F1 series of chips do not have 32-bit timers, F030 do not, specifically, see the data sheet.

Today the main summary about STM32F0 series input capture , capture signal frequency, that is, the so-called Logic Analyzer to detect the digital frequency function.

Today using 32-bit TIM2 as the capture timer, why is 32 bit, the reason is very simple, is to capture (capture) a wider frequency waveform, today provides the project can collect 0hz-10mhz waveform (recommended 2MHz, serial printing takes time). And 16 will not, remind the use of F1 friends to pay attention to this point. The official routine is also 16-bit, with a limited range of tests.

based on the principle of free sharing, If you feel that sharing content is useful to you, please Follow the public number " Embedddeveloper "There are many more wonderful content waiting for you.

Download

St Standard Peripheral Library and reference manuals, data sheets, etc. can be downloaded from the St official website , you can also go to my 360 cloud disk download. There are several versions of the reference manual for the F0 series of chips (for F0 different chips), but there is a generic version, which is "stm32f0x128 reference manual V8 (English) 2015-07" recommended reference to this manual, later if you switch to a type of chip is also easy to understand.

Today's Software engineering (360 cloud disk):

Https://yunpan.cn/cSztEbetLczKY access password 06d0

STM32F0XX information can be downloaded from my 360 cloud disk:

https://yunpan.cn/cS2PVuHn6X2Bj access password 8c37

Today's engineering test results (VIDEO):

https://yunpan.cn/cSziVGGZbMagj access password 5731

Preparatory work

Today's summary of software engineering is based on the "TIM Basic Delay configuration Detailed process" modified, so you need to prepare the software engineering download. Add the source code to the timer.c file Today, you do not need to create a new file.

Capture principle

Look at the system block diagram, today using frequency division to collect waveforms, the official provision of the routine is not configured timebase parameters, there is no crossover, the advantage of crossover is not very real-time to obtain the waveform, so as to provide accuracy (can be said to calculate the average). Capture the external 8 pulses, read the value of the count before and after, this value is the difference of the external pulse, thus calculating the frequency.

Configuration process Details

①RCC Clock

The function is located under the BSP. c file;

I'm personally accustomed to the first step of configuring the clock, ST 's officially provided routines also put the configuration clock in front. The configuration of the RCC clock is important, several times I just forgot to configure the corresponding RCC clock, let me find a long time problem, finally found that the RCC The clock is not configured.

Attention:

Peripheral clocks should not be arbitrarily added, such as:RCC_APB1 Peripherals do not configure in the rcc_apb2 Clock " such as:Rcc_apb2periphclockcmd (RCC _AHBPERIPH_DMA1, ENABLE); This can be compiled, but the wrong "

I warn the RCC clock every time because many people are having trouble with the software because of the clock, so remind more people to be careful about configuring RCC.

② Capture PIN Configuration

The function is located under the timer. c file;

Key notes:

Pin configuration to match the corresponding channel (see the PIN description in the data sheet).

The reuse function is also required for configuration.

③tim Capture Configuration

The function is located under the timer. c file;

The crossover value here is configured to be the same for easy calculation.

Calculation of ④ capture frequency

The function is located under the stm32f0xx_it. c file;

This function is to capture interrupt function, collect 8 pulses before and after the interrupt, that is, read the count value, through the difference of the count value can be calculated frequency.

Description

STM32F0 's Chip software is well-compatible and can be applied to Many other models of F0 (see Manual, or test it yourself).

Today's project is based on the project "stm32f0xx_tim Basic Delay configuration Detailed process" modified, the above examples are summarized for reference only, if there is wrong, please understand.

At last

If you like what I share, and you want to know more about it, please follow the public number at the beginning of the article, the new content continues to be updated, and more exciting content will appear later.

Read the original

Stm32f0xx_tim input capture (compute frequency) configuration detail procedure

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.