初始化后,每次写入2900的数据,示波器测量输出为0,代码如下:
DAC_InitTypeDef dactype;
GPIO_InitTypeDef gpioinit;
/* GPIOA clock enable */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Configure PA.04 (DAC_OUT1) as analog */
gpioinit.GPIO_Pin = GPIO_Pin_4;
gpioinit.GPIO_Mode = GPIO_Mode_AN;
gpioinit.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &gpioinit);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
dactype.DAC_Trigger = DAC_Trigger_Software;
dactype.DAC_OutputBuffer = DAC_OutputBuffer_Disable;
dactype.DAC_WaveGenera
tion = DAC_WaveGeneration_None;
dactype.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0;
DAC_Init(DAC_Channel_1, &dactype);
DAC_Cmd(DAC_Channel_1, ENABLE);
上面是初始化dac部分,
DAC_SetChannel1Data(DAC_Align_12b_R, 2900);
DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);
上面是写入部分
请问各位大神,代码有什么问题没有呢?
“dactype.DAC_Trigger = DAC_Trigger_Software;”
有,他用的是软件触发源。
一周热门 更多>