新手入门
- 积分
- 9
- 金钱
- 9
- 注册时间
- 2016-6-16
- 在线时间
- 1 小时
|
3金钱
void Dac7612_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_Init(GPIOC, &GPIO_InitStructure);
}
void Convert_DAC7612(unsigned int Byte)
{
char i;
uint number=0x2000;
LOADDACS =0;
CLK=1;
CS=1;
delay_us(4);
LOADDACS =1;
delay_us(4);
CS=0;
delay_us(4);
for(i=0;i<14;i++)
{
CLK=0;
//delay_us(15);
if(Byte&number)
{
SDI=1;
}
else
{
SDI=0;
}
delay_us(4);
CLK=1;
number = number >>1;
delay_us(4);
}
CS=1;
delay_us(4);
LOADDACS =0;
delay_us(4);
LOADDACS =1;
delay_us(4);
}
上面是7612的配置,为什么始终没有模拟输出,DAC是串行输入,但与STM32并没有使用串口,而是使用的普通IO口来模拟。
|
|