DAC 配置具体如下
void DAC_Configuration(void)
{
DAC_InitTypeDef DAC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* DAC Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
/* Configure DAC_CH1,DAC_CH2 output pin */
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_DAC1 | GPIO_PIN_DAC2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* DAC channel1 Configuration */
DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude =DAC_TriangleAmplitude_4095;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
DAC_Init(DAC_Channel_1, &DAC_InitStructure);
/* DAC channel2 Configuration */
DAC_InitStructure.DAC_Trigger = DAC_Trigger_Software;
DAC_InitStructure.DAC_WaveGeneration = DAC_WaveGeneration_None;
DAC_InitStructure.DAC_LFSRUnmask_TriangleAmplitude =DAC_TriangleAmplitude_4095;
DAC_InitStructure.DAC_OutputBuffer = DAC_OutputBuffer_Enable;
DAC_Init(DAC_Channel_2, &DAC_InitStructure);
DAC_Cmd(DAC_Channel_1, ENABLE);
DAC_Cmd(DAC_Channel_2, ENABLE);
// DAC_SetDualChannelData(DAC_Align_12b_R, 375, 375);
// DAC_DualSoftwareTriggerCmd(ENABLE);
}
问题:
1,管脚应该配置成GPIO_Mode_Out_PP;还是GPIO_Mode_AIN;
两种配置都试过,DAC都可以正常运行。
2, DAC_SetDualChannelData(DAC_Align_12b_R, 0, 0);
DAC_DualSoftwareTriggerCmd(ENABLE);
这样管脚输出是不是应该为0,但是我这边两个管脚都有65MV的电压(管脚后级都断开的情况下)。 |