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.
Previous article:STM32_ADC single channel single acquisition
Next article:STM32_SPI read and write Flash
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- How to measure analog voltage using the ADC of MSP430?
- Problems with the primary absorption clamp circuit in the flyback circuit
- How to use MSO5 series oscilloscope to capture abnormal signals?
- Analysis of interrupt processing of S3C2410 && WinCE6.0
- What is the impedance of a power module?
- I didn’t expect that Musk’s SpaceX manned spacecraft programming used C++ and Python
- ESP32-S2-Saola-1 运行 circuitpython(2)
- Sinlinx A33 realizes LED driver
- Do MCU ADC input pins require series resistors? Why?
- 4.3 inch LCD screen driver