STM32F0XX_DAC output voltage Configuration detailed procedure

Source: Internet
Author: User

Objective

The function of the digital-to-analog converter DAC is much smaller than the timer Tim, the serial port Usart, and so on, which is why the internal integrated DAC module is not so many. However, in a project that requires the use of a digital-to-analog conversion function, this DAC module can basically replace the plug-in DAC chip, because this module is also very powerful, only need to be simple configuration can output the specified voltage signal (such as: PWM waveform, triangular wave, positive selection wave), no need for software intervention midway. Of course, today's software engineering provides only the basic operation of the output voltage, no special waveform output. However, when you understand the principle of output voltage, it is much easier for you to output these special waveforms later.

The DAC functions of the STM32F0 series are mostly single-channel, relatively simple. Only the STM32F072 series chip is two output channels, the DAC control unit output Triangle waveform and so on.

Today mainly summarizes the basic operation of the DAC output voltage. The function of the output triangle wave, the positive selection wave is relatively complicated. Post-finishing a copy, please wait.

based on the principle of free sharing, if you feel that the content that you share is useful to you, approve the article that I share, please use the search " Embedddeveloper "or scan the QR code below, pay attention, and have more exciting 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/cSIyxQKbvcQi6 access password 3e6b

STM32F0XX information can be downloaded from my 360 cloud disk:

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

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. Open Software Engineering, create new source program Files (DAC.C and dac.h), add new source program files to the project DAC.C and use to standard peripheral library STM32F0XX_DAC.C. The source file code for the added source response is OK .

Principle of digital-to-analog conversion

As can be seen from the system diagram, this control unit is relatively simple, so the software in the operation of these registers is relatively simple.

The beginning of the article said that the DAC can output the specified voltage signal (such as: PWM waveform, triangular wave, positive selection wave), in fact, the principle of these signals is very simple, is to use the timer to trigger the DAC output, the signal amplitude needs to be generated with a specific algorithm (more project requirements). Of course, the project provided today is a fixed output of a voltage signal, just configure the output value on the line.

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.

②DAC Output PIN Configuration

The function is located under the DAC. c file;

Attention:

Here the pin PA4 configuration is determined for the output channel and must match (see the pin description in the data sheet). only the stm32f072 in the F0 Chip has two channels, which is the only way to configure PA5.

③DAC Output Configuration

The function is located under the DAC. c file;

Key notes:

Here the red mark three items need to pay attention to, the special produce waveform this one parameter, only F0 chip only stm32f072 can be other value, other chip is fixed this parameter. Likewise, the channel is.

Calculation of ④ output voltage

The function is located under the DAC. c file;

Since the reference voltage of the F0 chip is fixed to VDD, unlike other models, an external reference voltage can be used, so 3.3 is the value of the reference voltage in the calculation method here. 4096 is a 2 - Time Square. If you don't understand, please think for yourself.

Description

Perhaps your hardware chip is not to provide the chip inside the project, but stm32f0 chip software compatibility is very good, can be applied to F0 many other models of chips, even F2, F4 and other chips (see the manual, or personally test).

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_DAC output voltage Configuration detailed 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.