In a recent project, I used the DAC function of the STM8L151 chip. After referring to the routines on the official website, the DA output was still incorrect.
Later, I searched for information from other great programmers on Baidu and found that one of them had an extra statement to turn on the comparator clock. I also added this statement to the code, and the result was correct.
Below is the DAC initialization code
void DAC_Config(void)
{
CLK_PeripheralClockConfig(CLK_Peripheral_DAC, ENABLE); //Turn on DAC power
CLK_PeripheralClockConfig(CLK_Peripheral_COMP,ENABLE); //Note that COMP must be turned on, otherwise the RI register cannot be configured. The reason is not clear.
// RI->IOCMR3 |= 0X10;
SYSCFG_RIDeInit(); //port selection initialization
SYSCFG_RIIOSwitchConfig(RI_IOSwitch_14,ENABLE); //Select the specified channel
DAC_Init(DAC_Channel_1,DAC_Trigger_None,DAC_OutputBuffer_Disable);
// DAC_SetChannel1Data(DAC_Align_12b_R,2048);
DAC_Cmd(DAC_Channel_1,DISABLE);
nop();
}
da can be output normally
Previous article:STM8 real-time clock PCF8563 and infrared door entry reminder
Next article:STM8 GPIO modes
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Introducing the TI C2000 stack evaluation method
- MicroPython's official documentation has been significantly adjusted
- DISP0_CONTRAST is used as GPIO to drive LED
- (Bonus 6) GD32L233 Review - Random Numbers (with software random number generation algorithm)
- Disassembly of a compact portable negative ion generator
- Half-bridge DC/DC power supply based on LM5036
- Share ESP8266smartconfig source code
- The voltage of HM1548 cannot be raised to 24V. I have tried 10UH inductor and 22UF capacitor, but they are not good. Can someone take a look at it?
- Live broadcast has ended: Watch the Thanksgiving live broadcast and win an oscilloscope | High-speed oscilloscope basics and Keysight's new oscilloscope analysis
- BlueNRG-1 LSM6DSL Direction Detection