关于DAC输出问题
我按着资料写了一个DAC输出,可是为什么就是我在测试PA4脚时就是没有输出,知道帮忙说一下是什么原因,谢谢。int main(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
DAC_InitTypeDef DAC_InitStructure;
RCC_Configuration();//配置时钟
delay_ms(1);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC,ENABLE);
DAC_DeInit();
//配置PA4
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AIN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_SetBits(GPIOA,GPIO_Pin_4);
//配置DAC
DAC_InitStructure.DAC_Trigger=DAC_Trigger_None;
DAC_InitStructure.DAC_WaveGeneration=DAC_WaveGeneration_None;
DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude=DAC_LFSRUnmask_Bit0;//屏蔽、幅值设置
DAC_InitStructure.DAC_OutputBuffer=DAC_OutputBuffer_Disable;//Disable
DAC_Init(DAC_Channel_1,&DAC_InitStructure);
DAC_Cmd(DAC_Channel_1,ENABLE);
DAC_SetChannel1Data(DAC_Align_12b_R,0);
//DAC_SoftwareTriggerCmd(DAC_Channel_1, ENABLE);
while(1){DAC_SetChannel1Data(DAC_Align_12b_R,2000);}//这个值我什么改,输出都不会有的,知道帮忙看一下,再次谢谢。
}
我的芯片是STM32F103C8,我查了应是可以支持的吧。
页:
[1]