打印

STM32F103的DAC没有输出,不知哪里配置出了问题,求救!

[复制链接]
556|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
求关注啊|  楼主 | 2020-4-21 02:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
以下是我的代码,求大神们帮忙看看哪里有错!谢了!
//主函数
int main(void)
{        
        DAC_Configuration();
        while(1)
        {

        }
}
//DAC配置函数

void DAC_Configuration(void)
{
        DAC_InitTypeDef DAC_InitStruct;
        GPIO_InitTypeDef GPIO_InitStruct;

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

        GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
        GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_Init( GPIOA, &GPIO_InitStruct );

        DAC_InitStruct.DAC_Trigger = DAC_Trigger_Software;
        DAC_InitStruct.DAC_WaveGeneration = DAC_WaveGeneration_None;
        DAC_InitStruct.DAC_LFSRUnmask_TriangleAmplitude = DAC_LFSRUnmask_Bit0;
        DAC_InitStruct.DAC_OutputBuffer = DAC_OutputBuffer_Disable;

        DAC_Init( DAC_Channel_1, &DAC_InitStruct );
        DAC_Cmd( DAC_Channel_1, ENABLE );
        DAC_SetChannel1Data( DAC_Align_12b_R, 0X0FFF );
        DAC_SoftwareTriggerCmd( DAC_Channel_1, ENABLE );
}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

380

主题

380

帖子

0

粉丝