OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3653|回复: 0

F429外接AD9851出现问题,求指点

[复制链接]

4

主题

8

帖子

0

精华

新手上路

积分
31
金钱
31
注册时间
2019-5-28
在线时间
14 小时
发表于 2019-8-7 21:18:24 | 显示全部楼层 |阅读模式
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);
}

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-5-15 20:16

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表