问答

汇集网友智慧,解决技术难题

21ic问答首页 - HK32F103VET6 DAC1 输出电压异常问题

输出电压 DAC HK32F103 ni IO pi

HK32F103VET6 DAC1 输出电压异常问题

wwddgod2021-07-30
void DAC_Configuration(void)
{
DAC_InitTypeDef   DAC_InitStructure;
GPIO_InitTypeDef  GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;          //
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;    //
   GPIO_Init(GPIOA, &GPIO_InitStructure);      //A¶Ë¿Ú
  //DAC_DeInit();
//   DAC_Cmd(DAC_Channel_1,ENABLE); //
   DAC_StructInit(&DAC_InitStructure);//½«DAC_StructµÄÖµÉèΪĬÈÏ
   DAC_InitStructure.DAC_Trigger=DAC_Trigger_Software;//ÓÉÈí¼þ´¥·¢
   DAC_InitStructure.DAC_WaveGeneration=DAC_WaveGeneration_None;//¹Ø±Õ²¨ÐÎÉú³É
   DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude=DAC_TriangleAmplitude_4095;
   DAC_InitStructure.DAC_OutputBuffer=DAC_OutputBuffer_Enable;//ʹÄÜDACͨµÀ»º´æ   
   DAC_Init(DAC_Channel_1,&DAC_InitStructure);  
    /* Enable DAC Channel1 */
   DAC_Cmd(DAC_Channel_1, ENABLE);
DAC_SetChannel1Data(DAC_Align_12b_R,4085);
DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE);
while(1)
{
  DAC_SetChannel1Data(DAC_Align_12b_R,4085);
DAC_SoftwareTriggerCmd(DAC_Channel_1,ENABLE);
}

源代码如上,输出电压不对,试过其他数值也不对,代码之前是用在ST上的
回答 +关注 15
2230人浏览 0人回答问题 分享 举报
0 个回答

您需要登录后才可以回复 登录 | 注册