新手上路
- 积分
- 34
- 金钱
- 34
- 注册时间
- 2018-6-28
- 在线时间
- 33 小时
|
1金钱
本帖最后由 hyl88099 于 2018-7-9 17:29 编辑
void DAC_SPEED(int temp)
{
GPIO_InitTypeDef GPIO_InitStructure;
DAC_InitTypeDef DAC_InitStructure;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;
GPIO_CFG(20, _IN_IO , P_AN);
GPIO_SetBits(GPIOA,GPIO_Pin_4);
GPIO_Init(GPIOA,&GPIO_InitStructure);
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC,ENABLE);
DAC_InitStructure.DAC_Trigger=DAC_Trigger_None;
DAC_InitStructure.DAC_OutputBuffer=DAC_OutputBuffer_Disable;
//DAC_SetChannel1Data(DAC_Align_12b_R,temp);
DAC_Init(DAC_Channel_1,&DAC_InitStructure);
DAC_Cmd(DAC_Channel_1,ENABLE);
DAC_SetChannel1Data(DAC_Align_12b_R,temp);
}
int SPEED;
void DAC_Control_forward()
{
int times;
GPIO_SetBits(GPIOB,GPIO_Pin_10);
for(times=0;times<2;times++)
{
DAC_SPEED(0);
for(SPEED=2000;SPEED<4096;SPEED++)
{
DAC_SPEED(SPEED);
delay_us(1000);
}
}
}
这是本人写的一个DAC的程序,发现当SPEED最大为4095时输出最大模拟电压只有2.9V左右,但Vref有3.2V,为什么输出达不到最大值,请大神指导
|
|