新手上路
- 积分
- 31
- 金钱
- 31
- 注册时间
- 2019-5-28
- 在线时间
- 14 小时
|
1金钱
要使用F4外界DDS模块 但是移植了一直不成功 有大佬指点一下吗
int main(void)
{
int i=0;
double frequence=1000;
LED_GPIO_Config();
AD9851_IO_Init();
ad9851_reset();
ad9851_wr_parrel(0x01,2000);
while (1)
{
LED1( ON ); // áá
Delay(0xFFFFFF);
LED1( OFF ); // Ãe
Delay(0xFFFFFF);
}
}
void AD9851_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(ad9851_w_clk_GPIO_CLK, ENABLE); //ê1ÄüPB,PE¶Ë¿úê±Öó
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);//ê1ÄüGPIOBê±Öó
GPIO_InitStructure.GPIO_Pin = ad9851_w_clk_PIN|ad9851_fq_up_PIN|ad9851_rest_PIN;
/*éèÖÃòy½ÅÄ£ê½Îaêä3öÄ£ê½*/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
/*éèÖÃòy½ÅμÄêä3öààDíÎaíÆíìêä3ö*/
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
/*éèÖÃòy½ÅÎaéÏà-Ä£ê½*/
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
/*éèÖÃòy½ÅËùÂêÎa2MHz */
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
/*μ÷óÿaoˉêy£¬ê1óÃéÏÃæÅäÖÃμÄGPIO_InitStructure3õê¼»ˉGPIO*/
GPIO_Init(ad9851_w_clk_GPIO_PORT, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;//LED0oíLED1¶Ôó|IO¿ú
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//ÆÕí¨êä3öÄ£ê½
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//íÆíìêä3ö
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//25MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;//ÏÂà-
GPIO_Init(GPIOB, &GPIO_InitStructure);//3õê¼»ˉGPIO
GPIO_ResetBits(GPIOB,GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_5);
GPIO_ResetBits(GPIOH,GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5);
}
void ad9851_wr_parrel(unsigned char w0,double frequence)
{
unsigned char w;
long int y;
double x;
//¼ÆËãÆμÂêμÄHEXÖμ
x=4294967295/180;//êêoÏ180M¾§Õñ/180Îa×îÖÕê±ÖóÆμÂ꣨»ò30Máù±¶Æμ£©
//èç1ûê±ÖóÆμÂê2»Îa180MHZ£¬DT¸Ä¸Ã′|μÄÆμÂêÖ죬μ¥λMHz £¡£¡£¡
frequence=frequence/1000000;
frequence=frequence*x;
y=frequence;
//D′w0êy¾Y
w=w0;
GPIO_Write(GPIOB,w|(GPIO_ReadOutputData(GPIOB)&0xff00)); //w0
ad9851_w_clk(ON);
ad9851_w_clk(OFF);
//D′w1êy¾Y
w=(y>>24);
GPIO_Write(GPIOB,w|(GPIO_ReadOutputData(GPIOB)&0xff00)); //w1
ad9851_w_clk(ON);
ad9851_w_clk(OFF);
//D′w2êy¾Y
w=(y>>16);
GPIO_Write(GPIOB,w|(GPIO_ReadOutputData(GPIOB)&0xff00)); //w2
ad9851_w_clk(ON);
ad9851_w_clk(OFF);
//D′w3êy¾Y
w=(y>>8);
data=w|(GPIO_ReadOutputData(GPIOB)&0xff00);
GPIO_Write(GPIOB,w|(GPIO_ReadOutputData(GPIOB)&0xff00)); //w3
ad9851_w_clk(ON);
ad9851_w_clk(OFF);
//D′w4êy¾Y
w=(y>>=0);
GPIO_Write(GPIOB,w|(GPIO_ReadOutputData(GPIOB)&0xff00)); //w4
ad9851_w_clk(ON);
ad9851_w_clk(OFF);
//òÆèëê¼Äü
ad9851_fq_up(ON);
ad9851_fq_up(OFF);
}
void ad9851_reset()
{
ad9851_w_clk(OFF);
ad9851_fq_up(OFF);
//restDÅoÅ
ad9851_rest(OFF);
ad9851_rest(ON);
ad9851_rest(OFF);
}
|
|