初级会员

- 积分
- 61
- 金钱
- 61
- 注册时间
- 2022-8-10
- 在线时间
- 11 小时
|
5金钱
用原子哥的DAC实验代码把DAC通道1改成通道2输出,但是将PA1和PA5相连时输出和输入不等,有一个初始值,如图所示。
- void Dac1_Init(void)
- {
-
- GPIO_InitTypeDef GPIO_InitStructure;
- DAC_InitTypeDef DAC_InitType;
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE );
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE );
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_Init(GPIOA, &GPIO_InitStructure);
- GPIO_SetBits(GPIOA,GPIO_Pin_5) ;
-
- DAC_InitType.DAC_Trigger=DAC_Trigger_None;
- DAC_InitType.DAC_WaveGeneration=DAC_WaveGeneration_None;
- DAC_InitType.DAC_LFSRUnmask_TriangleAmplitude=DAC_LFSRUnmask_Bit0;
- DAC_InitType.DAC_OutputBuffer=DAC_OutputBuffer_Disable ;
- DAC_Init(DAC_Channel_2,&DAC_InitType);
- DAC_Cmd(DAC_Channel_2, ENABLE);
-
- DAC_SetChannel2Data(DAC_Align_12b_R, 0);
- }
复制代码
|
|