PA4无电压输出啊!求解!!!
DAC配置如下:
void Dac1_Init(void)
{
DAC_InitTypeDef DAC_InitStruct;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
/* Configure DAC channe1 outputs pins */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
DAC_DeInit();
//DAC_Cmd(DAC_Channel_1,ENABLE); //
//DAC_Cmd(DAC_Channel_2, ENABLE);
DAC_StructInit(&DAC_InitStruct);//将DAC_Struct的值设为默认
DAC_InitStruct.DAC_Trigger=DAC_Trigger_Software;//由软件触发
DAC_InitStruct.DAC_WaveGeneration=DAC_WaveGeneration_None;//关闭波形生成
DAC_InitStruct.DAC_LFSRUnmask_TriangleAmplitude=DAC_TriangleAmplitude_4095;
DAC_InitStruct.DAC_OutputBuffer=DAC_OutputBuffer_Disable;//使能DAC通道缓存
DAC_Init(DAC_Channel_1,&DAC_InitStruct);
/* Enable DAC Channel1 */
DAC_DualSoftwareTriggerCmd(ENABLE);//使能软件触发,更新DAC的值
DAC_SetChannel1Data(DAC_Align_12b_R,4000);//12位右对齐,
DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);
DAC_Cmd(DAC_Channel_1, ENABLE);
}
主函数中:
Dac1_Init(); DAC_SetChannel1Data(DAC_Align_12b_R, 4000); DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);
测PA4无电压输出啊!求解!!! |