初中生
最后登录1970-1-1
在线时间 小时
注册时间2015-11-24
|
单片机型号为STM32F103RB,PA4和PA5用示波器一直看不到输出,不知道问题出在哪,下面附工程压缩包
测试.rar
(3.84 MB, 下载次数: 18)
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_AIN;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOA, &GPIO_InitStruct );
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AIN;
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_Init( DAC_Channel_2, &DAC_InitStruct );
DAC_Cmd( DAC_Channel_1, ENABLE );
DAC_Cmd( DAC_Channel_2, ENABLE );
DAC_SetChannel1Data( DAC_Align_12b_R, 0X3FF );
DAC_SoftwareTriggerCmd( DAC_Channel_1, ENABLE );
DAC_SetChannel2Data( DAC_Align_12b_R, 0X7FF );
DAC_SoftwareTriggerCmd( DAC_Channel_2, ENABLE );
}
|
|