以下是我的代码,求大神们帮忙看看哪里有错!谢了!
//主函数
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 );
} |