最近使用STM32F405RGT6驱动AD9850,程序是从51单片机的程序改过来的,但是AD9850怎么都没有波形!!!!哪位大神可以指点一二啊!!!跪求!!!
void AD9850_Gpio_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_SetBits(GPIOC,GPIO_Pin_15 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7);
};
(头文件中有定义:
#define ad9850_w_clk PCout(6)
#define ad9850_fq_up PCout(7)
#define ad9850_rest PCout(5)
#define ad9850_bit_data PCout(15))
void ad9850_reset_serial(void)
{
ad9850_w_clk = 0;
ad9850_fq_up = 0;
ad9850_rest = 0;
ad9850_rest = 1;
ad9850_rest = 0;
ad9850_w_clk = 0;
ad9850_w_clk = 1;
ad9850_w_clk = 0;
ad9850_fq_up = 0;
ad9850_fq_up = 1;
ad9850_fq_up = 0;
};
void ad9850_wr_serial(unsigned char w0,double frequence)
{
unsigned char w;
int i;
long int y;
double x;
x = 4294967295U/125;
frequence = frequence/1000000;
frequence = frequence * x;
y=frequence;
w = (y>>=0);
for(i=0;i<8;i++)
{
ad9850_bit_data = (w>>i)&0x01;
ad9850_w_clk = 1;
ad9850_w_clk = 0;
}
// LED2 = 1;
w = (y>>8);
for(i=0;i<8;i++)
{
ad9850_bit_data = (w>>i)&0x01;
ad9850_w_clk = 1;
ad9850_w_clk = 0;
}
// LED2 = 0;
w = (y>>16);
for(i=0;i<8;i++)
{
ad9850_bit_data = (w>>i)&0x01;
ad9850_w_clk = 1;
ad9850_w_clk = 0;
}
// LED2 = 1;
w = (y>>24);
for(i=0;i<8;i++)
{
ad9850_bit_data = (w>>i)&0x01;
ad9850_w_clk = 1;
ad9850_w_clk = 0;
}
// LED2 = 0;
w = w0;
for(i=0;i<8;i++)
{
ad9850_bit_data = (w>>i)&0x01;
ad9850_w_clk = 1;
ad9850_w_clk = 0;
}
ad9850_fq_up = 1;
ad9850_fq_up = 0;
//LED2 = 1;
};
|