STM32_DAC output voltage

Publisher:TechGuru123Latest update time:2017-09-15 Source: eefocusKeywords:STM32  DAC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Today we will explain the "STM32F103 DAC output voltage" function.

 

The software project provided and explained today is modified based on the software project "A0.0.0 (STM32F10x_TIM delay)". If you don't know how it came about, please follow the WeChat public account "EmbeddDeveloper" for more information.

Based on the principle of free sharing, the source code of the project explained will be shared with everyone. I also hope that friends who see it will follow and promote the WeChat public account to increase its popularity.

The "software engineering" provided for download every day is tested multiple times on the hardware board and is uploaded to the 360 ​​cloud disk only after it is guaranteed to be problem-free.

 

Today's software engineering download address (360 cloud disk):

https://yunpan.cn/cPU3YIHzcu6Eu   Access password: 11f0

 

The information of STM32F10x can be downloaded from my 360 cloud disk:

https://yunpan.cn/crBUdUGdYKam2Access    password ca90

 

Regarding "STM32F103 DAC output voltage" I will explain the important points below. If you don’t understand, please follow the WeChat public account "EmbeddDeveloper" to check or leave a message.

 

1. RCC clock configuration

 

This function is located under the bsp.c file;

Enable RCC clock: RCC_APB1Periph_DAC

Here, the DA clock is not like AD which has AD1, AD2, etc. DA uses a shared clock, so when calling the connection function, you must distinguish between DA1 and DA2.

 

2. Pin Configuration

 

This function is located under the dac.c file;

Configure the pins used by DA channel 1.

Notice:

The DAC_OUT1 pin here is fixed to PA4. Once the DA1 function is started, this pin will be used for the DAC function.

 

DAC Configuration

 

This function is located under the dac.c file;

Configure the DA.

Each statement in the configuration is commented, please see the source code.

The configurations here are relatively basic, and I will explain more complex configurations later (the first stage is positioned at the elementary level, so if you want to know more advanced functions, please continue to pay attention to my WeChat public account).

 

4. Output voltage

 

This function is located under the dac.c file;

By calling this interface, the corresponding voltage value can be output on the PA4 pin (note that this interface is applicable to the case where the reference voltage is 3.3V. If the reference voltage is changed, the conversion formula must also be changed accordingly. Anyone who reads the source code should know how to modify it).

Here the conversion is initiated using software, and other methods will be used to trigger it later.

 

5. Main function application

 

This function is located below the main.c file;

The main thing is to configure DA at power-on and let it output 1.5V voltage on the PA4 pin.

You can see the phenomenon: every 500ms, the LED changes and the serial port prints out a string.

 

6. Today’s key tips

A. The configurations of DA1 and DA2 are basically the same;

B. To avoid parasitic interference and extra power consumption, pin PA4 or PA5 should be set to analog input (AIN) before, so it is configured as: GPIO_Mode_AIN in the pin configuration place.


Keywords:STM32  DAC Reference address:STM32_DAC output voltage

Previous article:STM32_ADC single channel single acquisition
Next article:STM32_SPI read and write Flash

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号