STM8L chip DA function initialization attention

Publisher:Susan苏Latest update time:2019-12-16 Source: eefocusKeywords:STM8L Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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


Keywords:STM8L Reference address:STM8L chip DA function initialization attention

Previous article:STM8 real-time clock PCF8563 and infrared door entry reminder
Next article:STM8 GPIO modes

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号