久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 7774|回復(fù): 5
打印 上一主題 下一主題
收起左側(cè)

ADF4351 stm32103驅(qū)動(dòng)代碼分享

  [復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:421115 發(fā)表于 2018-11-5 15:41 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
keil5的程序

單片機(jī)源程序如下:
  1. #include "ADF4351.h"

  2. #define SET_LE()                GPIO_SetBits(GPIOD, GPIO_Pin_8)        //P4.3->LE
  3. #define CLR_LE()                GPIO_ResetBits(GPIOD, GPIO_Pin_8)

  4. #define        SET_SCL()                GPIO_SetBits(GPIOD, GPIO_Pin_10)        //P4.4->SCL
  5. #define        CLR_SCL()                GPIO_ResetBits(GPIOD, GPIO_Pin_10)

  6. #define SET_DATA()                GPIO_SetBits(GPIOD, GPIO_Pin_11)        //P4.5->DATA
  7. #define CLR_DATA()                GPIO_ResetBits(GPIOD, GPIO_Pin_11)

  8. #define SET_CE()                GPIO_SetBits(GPIOD, GPIO_Pin_9)        //P4.3->CE
  9. #define CLR_CE()                GPIO_ResetBits(GPIOD, GPIO_Pin_9)
  10.         
  11. u8 buf[4];


  12. //寫入32個(gè)字節(jié)
  13. void ADF4351_Write(u32 adf_dat)
  14. {
  15.         u8 i;

  16.         CLR_LE();
  17.         for (i = 0; i < 32; i++)
  18.         {
  19.                 if ((adf_dat & 0x80000000) == 0x80000000)
  20.                         SET_DATA();
  21.                 else
  22.                         CLR_DATA();
  23.                 CLR_SCL();
  24.                 SET_SCL();
  25.                 CLR_SCL();
  26.                 adf_dat <<= 1;
  27.         }
  28.         SET_LE();
  29.         delay(1);
  30.         CLR_LE();
  31. }

  32. void delay (int length)
  33. {
  34.         int i;
  35.         i = length * 200 ;
  36.         while (i >0)
  37.         i--;
  38. }

  39. void ADF4351_Initiate(void)
  40. {
  41.                 GPIO_InitTypeDef  GPIO_InitStructure;
  42.                
  43.                 RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOD, ENABLE); ;
  44.                
  45.                 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_14 ;
  46.                 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;   
  47.                 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                 
  48.                 GPIO_Init(GPIOD, &GPIO_InitStructure);   
  49.            SET_CE();
  50.         
  51.         
  52.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
  53.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  54.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  55.         GPIO_Init(GPIOB, &GPIO_InitStructure);
  56.         GPIO_ResetBits(GPIOD, GPIO_Pin_1);        //PDRF恒為0

  57. }




  58. //---------------------------------
  59. //void WriteToADF4350(unsigned char count,unsigned char *buf);
  60. //---------------------------------
  61. //Function that writes to the ADF4350 via the SPI port.
  62. //--------------------------------------------------------------------------------


  63. void WriteToADF4350(unsigned char count, unsigned char *buf)
  64. {
  65.         unsigned        char        ValueToWrite = 0;
  66.     unsigned        char        i = 0;
  67.         unsigned        char        j = 0;
  68.         
  69.         
  70.         delay(1);
  71.         CLR_SCL();
  72.         CLR_LE();
  73.         delay(1);

  74.         for(i=count;i>0;i--)
  75.          {
  76.                  ValueToWrite = *(buf + i - 1);
  77.                 for(j=0; j<8; j++)
  78.                 {
  79.                         if(0x80 == (ValueToWrite & 0x80))
  80.                         {
  81.                                 SET_DATA();          //Send one to SDO pin
  82.                         }
  83.                         else
  84.                         {
  85.                                 CLR_DATA();          //Send zero to SDO pin
  86.                         }
  87.                         delay(1);
  88.                         SET_SCL();
  89.                         delay(1);
  90.                         ValueToWrite <<= 1;        //Rotate data
  91.                         CLR_SCL();
  92.                 }
  93.         }
  94.         CLR_DATA();
  95.         delay(1);
  96.         SET_LE();
  97.         delay(1);
  98.         CLR_LE();
  99. }


  100. //---------------------------------
  101. //void ReadFromADF4350(unsigned char count,unsigned char *buf)
  102. //---------------------------------
  103. //Function that reads from the ADF4350 via the SPI port.
  104. //--------------------------------------------------------------------------------
  105. void ReadFromADF4350(unsigned char count, unsigned char *buf)
  106. {
  107.         unsigned        char        i = 0;
  108.         unsigned        char        j = 0;
  109.         unsigned        int          iTemp = 0;
  110.         unsigned        char          RotateData = 0;


  111.         
  112.         delay(1);
  113.         CLR_SCL();
  114.         CLR_LE();
  115.         delay(1);

  116.         for(j=count; j>0; j--)
  117.         {
  118.                 for(i=0; i<8; i++)
  119.                 {
  120.                         RotateData <<= 1;                //Rotate data
  121.                         delay(1);
  122. //                        iTemp = GP4DAT;                        //Read DATA of ADF4350
  123.                         SET_SCL();        
  124.                         if(0x00000020 == (iTemp & 0x00000020))
  125.                         {
  126.                                 RotateData |= 1;        
  127.                         }
  128.                         delay(1);
  129.                         CLR_SCL();
  130.                 }
  131.                 *(buf + j - 1)= RotateData;
  132.         }         
  133.         delay(1);
  134.         SET_LE();
  135.         delay(1);
  136.         CLR_LE();
  137. }

  138. void Frequency_100MHz(void)
  139. {

  140.         buf[3] = 0x00;
  141.         buf[2] = 0x58;
  142.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  143.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  144.         WriteToADF4350(4,buf);               

  145.         buf[3] = 0x00;
  146.         buf[2] = 0xDC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  147.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  148.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  149.         WriteToADF4350(4,buf);               

  150.         buf[3] = 0x00;
  151.         buf[2] = 0x00;
  152.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  153.          buf[0] = 0xB3;
  154.         WriteToADF4350(4,buf);        

  155.         buf[3] = 0x00;
  156.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  157.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  158.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  159.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  160.         buf[3] = 0x08;
  161.         buf[2] = 0x00;
  162.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  163.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  164.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  165.                                                            //(DB27=1)prescaler value is 8/9

  166.         buf[3] = 0x00;
  167.         buf[2] = 0x40;
  168.         buf[1] = 0x00;
  169.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  170.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  171. }

  172. void Frequency_200MHz(void)
  173. {

  174.         buf[3] = 0x00;
  175.         buf[2] = 0x58;
  176.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  177.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  178.         WriteToADF4350(4,buf);               

  179.         buf[3] = 0x00;
  180.         buf[2] = 0xCC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  181.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  182.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  183.         WriteToADF4350(4,buf);               

  184.         buf[3] = 0x00;
  185.         buf[2] = 0x00;
  186.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  187.          buf[0] = 0xB3;
  188.         WriteToADF4350(4,buf);        

  189.         buf[3] = 0x00;
  190.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  191.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  192.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  193.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  194.         buf[3] = 0x08;
  195.         buf[2] = 0x00;
  196.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  197.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  198.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  199.                                                            //(DB27=1)prescaler value is 8/9

  200.         buf[3] = 0x00;
  201.         buf[2] = 0x40;
  202.         buf[1] = 0x00;
  203.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  204.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  205. }

  206. void Frequency_300MHz(void)
  207. {

  208.         buf[3] = 0x00;
  209.         buf[2] = 0x58;
  210.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  211.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  212.         WriteToADF4350(4,buf);               

  213.         buf[3] = 0x00;
  214.         buf[2] = 0xBC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  215.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  216.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  217.         WriteToADF4350(4,buf);               

  218.         buf[3] = 0x00;
  219.         buf[2] = 0x00;
  220.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  221.          buf[0] = 0xB3;
  222.         WriteToADF4350(4,buf);        

  223.         buf[3] = 0x00;
  224.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  225.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  226.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  227.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  228.         buf[3] = 0x08;
  229.         buf[2] = 0x00;
  230.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  231.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  232.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  233.                                                            //(DB27=1)prescaler value is 8/9

  234.         buf[3] = 0x00;
  235.         buf[2] = 0x30;
  236.         buf[1] = 0x00;
  237.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  238.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  239. }

  240. void Frequency_400MHz(void)
  241. {

  242.         buf[3] = 0x00;
  243.         buf[2] = 0x58;
  244.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  245.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  246.         WriteToADF4350(4,buf);               

  247.         buf[3] = 0x00;
  248.         buf[2] = 0xBC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  249.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  250.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  251.         WriteToADF4350(4,buf);               

  252.         buf[3] = 0x00;
  253.         buf[2] = 0x00;
  254.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  255.          buf[0] = 0xB3;
  256.         WriteToADF4350(4,buf);        

  257.         buf[3] = 0x00;
  258.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  259.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  260.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  261.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  262.         buf[3] = 0x08;
  263.         buf[2] = 0x00;
  264.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  265.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  266.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  267.                                                            //(DB27=1)prescaler value is 8/9

  268.         buf[3] = 0x00;
  269.         buf[2] = 0x40;
  270.         buf[1] = 0x00;
  271.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  272.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  273. }

  274. void Frequency_500MHz(void)
  275. {

  276.         buf[3] = 0x00;
  277.         buf[2] = 0x58;
  278.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  279.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  280.         WriteToADF4350(4,buf);               

  281.         buf[3] = 0x00;
  282.         buf[2] = 0xCC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  283.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  284.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  285.         WriteToADF4350(4,buf);               

  286.         buf[3] = 0x00;
  287.         buf[2] = 0x00;
  288.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  289.          buf[0] = 0xB3;
  290.         WriteToADF4350(4,buf);        

  291.         buf[3] = 0x00;
  292.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  293.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  294.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  295.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  296.         buf[3] = 0x08;
  297.         buf[2] = 0x00;
  298.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  299.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  300.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  301.                                                            //(DB27=1)prescaler value is 8/9

  302.         buf[3] = 0x00;
  303.         buf[2] = 0x50;
  304.         buf[1] = 0x00;
  305.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  306.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  307. }

  308. void Frequency_600MHz(void)
  309. {

  310.         buf[3] = 0x00;
  311.         buf[2] = 0x58;
  312.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  313.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  314.         WriteToADF4350(4,buf);               

  315.         buf[3] = 0x00;
  316.         buf[2] = 0xAC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  317.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  318.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  319.         WriteToADF4350(4,buf);               

  320.         buf[3] = 0x00;
  321.         buf[2] = 0x00;
  322.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  323.          buf[0] = 0xB3;
  324.         WriteToADF4350(4,buf);        

  325.         buf[3] = 0x00;
  326.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  327.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  328.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  329.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  330.         buf[3] = 0x08;
  331.         buf[2] = 0x00;
  332.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  333.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  334.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  335.                                                            //(DB27=1)prescaler value is 8/9

  336.         buf[3] = 0x00;
  337.         buf[2] = 0x30;
  338.         buf[1] = 0x00;
  339.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  340.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  341. }

  342. void Frequency_700MHz(void)
  343. {

  344.         buf[3] = 0x00;
  345.         buf[2] = 0x58;
  346.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  347.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  348.         WriteToADF4350(4,buf);               

  349.         buf[3] = 0x00;
  350.         buf[2] = 0xAC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  351.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  352.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  353.         WriteToADF4350(4,buf);               

  354.         buf[3] = 0x00;
  355.         buf[2] = 0x00;
  356.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  357.          buf[0] = 0xB3;
  358.         WriteToADF4350(4,buf);        

  359.         buf[3] = 0x00;
  360.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  361.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  362.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  363.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  364.         buf[3] = 0x08;
  365.         buf[2] = 0x00;
  366.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  367.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  368.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  369.                                                            //(DB27=1)prescaler value is 8/9

  370.         buf[3] = 0x00;
  371.         buf[2] = 0x38;
  372.         buf[1] = 0x00;
  373.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  374.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  375. }

  376. void Frequency_800MHz(void)
  377. {

  378.         buf[3] = 0x00;
  379.         buf[2] = 0x58;
  380.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  381.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  382.         WriteToADF4350(4,buf);               

  383.         buf[3] = 0x00;
  384.         buf[2] = 0xAC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  385.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  386.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  387.         WriteToADF4350(4,buf);               

  388.         buf[3] = 0x00;
  389.         buf[2] = 0x00;
  390.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  391.          buf[0] = 0xB3;
  392.         WriteToADF4350(4,buf);        

  393.         buf[3] = 0x00;
  394.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  395.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  396.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  397.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  398.         buf[3] = 0x08;
  399.         buf[2] = 0x00;
  400.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  401.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  402.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  403.                                                            //(DB27=1)prescaler value is 8/9

  404.         buf[3] = 0x00;
  405.         buf[2] = 0x40;
  406.         buf[1] = 0x00;
  407.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  408.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  409. }

  410. void Frequency_900MHz(void)
  411. {

  412.         buf[3] = 0x00;
  413.         buf[2] = 0x58;
  414.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  415.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  416.         WriteToADF4350(4,buf);               

  417.         buf[3] = 0x00;
  418.         buf[2] = 0xAC;                                //(DB23=1)The signal is taken from the VCO directly;(DB22-20:4H)the RF divider is 16;(DB19-12:50H)R is 80
  419.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  420.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  421.         WriteToADF4350(4,buf);               

  422.         buf[3] = 0x00;
  423.         buf[2] = 0x00;
  424.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  425.          buf[0] = 0xB3;
  426.         WriteToADF4350(4,buf);        

  427.         buf[3] = 0x00;
  428.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  429.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  430.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  431.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  432.         buf[3] = 0x08;
  433.         buf[2] = 0x00;
  434.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  435.          buf[0] = 0x11;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  436.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  437.                                                            //(DB27=1)prescaler value is 8/9

  438.         buf[3] = 0x00;
  439.         buf[2] = 0x48;
  440.         buf[1] = 0x00;
  441.          buf[0] = 0x00;                                //(DB14-3:0H)FRAC value is 0;
  442.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  443. }

  444. void Frequency_35MHz(void)
  445. {

  446.         buf[3] = 0x00;
  447.         buf[2] = 0x58;
  448.         buf[1] = 0x00;                                //write communication register 0x00580005 to control the progress
  449.          buf[0] = 0x05;                                //to write Register 5 to set digital lock detector
  450.         WriteToADF4350(4,buf);               

  451.         buf[3] = 0x00;
  452.         buf[2] = 0xDc;        //EC                        //(DB23=1)The signal is taken from the VCO directly;(DB22-20:6H)the RF divider is 64;(DB19-12:50H)R is 80
  453.         buf[1] = 0x80;                                //(DB11=0)VCO powerd up;
  454.          buf[0] = 0x3C;                                //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5
  455.         WriteToADF4350(4,buf);               

  456.         buf[3] = 0x00;
  457.         buf[2] = 0x00;
  458.         buf[1] = 0x04;                                //(DB14-3:96H)clock divider value is 150.
  459.          buf[0] = 0xB3;
  460.         WriteToADF4350(4,buf);        

  461.         buf[3] = 0x00;
  462.         buf[2] = 0x00;                                //(DB6=1)set PD polarity is positive;(DB7=1)LDP is 6nS;
  463.         buf[1] = 0x4E;                                //(DB8=0)enable fractional-N digital lock detect;
  464.          buf[0] = 0x42;                                //(DB12-9:7H)set Icp 2.50 mA;
  465.         WriteToADF4350(4,buf);                //(DB23-14:1H)R counter is 1

  466.         buf[3] = 0x08;
  467.         buf[2] = 0x00;
  468.         buf[1] = 0x80;                           //(DB14-3:6H)MOD counter is 6;
  469.          buf[0] = 0x29;                           //(DB26-15:6H)PHASE word is 1,neither the phase resync
  470.         WriteToADF4350(4,buf);           //nor the spurious optimization functions are being used
  471.                                                            //(DB27=1)prescaler value is 8/9

  472.         buf[3] = 0x00;
  473.         buf[2] = 0x2C;
  474.         buf[1] = 0x80;
  475.          buf[0] = 0x18;                                //(DB14-3:0H)FRAC value is 0;
  476.         WriteToADF4350(4,buf);                //(DB30-15:140H)INT value is 320;

  477. }



  478.         /*-------------------------------------200MHz---------------------------------------------
  479.         Reference frequency: 20MHz;Output frequency: 200MHz;VCO frequency: 3200MHz;Prescaler: 8/9;
  480.         RF divider: 16;VCO channel spacing frequency: 200KHz;PFD frequency: 10MHz;
  481.         INT: 320;FRAC: 0;MOD: 100;R: 1;Lock Clk Div: 6; bank clk div: 200; Phase: 1  
  482.         ----------------------------------------------------------------------------------------*/
  483.         /*RFout = [INT + (FRAC/MOD)] * (Fpfd/RF Divider)*/
  484.         /*Fpfd = REFIN * [(1 + D)/(R * (1 + T))]*/
  485.         /*Fvco = RF divider * Output frequency   2.2G-4.4G*/

  486. void ADF_SetFre(void){

  487.         u32 adf_data;
  488.         u16 adf_R=1;                //RF參考分頻系數(shù)
  489.   u8 adf_D=0;                //RF REFin倍頻器位(0 or 1)
  490.   u8 adf_T=0;                //參考二分頻位,產(chǎn)生占空比50%,減少周跳
  491.   u16 adf_Locktime=160;
  492.   u16 adf_MOD=1;
  493.   u16 adf_INT=256;
  494.   u16 adf_FARC=0;
  495.   u16 adf_PHASE=1;
  496.   u8 pinduan;
  497.         

  498.         CLR_SCL();
  499.         CLR_LE();
  500.         
  501.         
  502.         //配置寄存器5
  503.         adf_data = 0x00580000;        //數(shù)字鎖存   LD引腳的工作方式為數(shù)字鎖存   D23 D22=01
  504.         adf_data =adf_data | ADF_R5;        
  505.         ADF4351_Write(adf_data);
  506.         
  507.         
  508.         //配置寄存器4
  509.         adf_data = 0x00800038;
  510.         /*(DB23=1)The signal is taken from the VCO directly,信號(hào)直接從VCO獲得
  511.         可修改RF divider, R的值(DB22-20)the RF divider is 16;
  512.         (DB11=0)VCO powerd up;        輔助RF輸出禁用; 頻段選擇時(shí)鐘,分頻至125k, 分頻值160*/
  513.         adf_data = adf_data | (RF_div32 << 20);                //RF divider is 16
  514.         adf_data = adf_data | (160 << 12);                //頻段選擇時(shí)鐘
  515.         adf_data = adf_data | ADF_R4;        //(DB5=1)RF output is enabled;(DB4-3=3H)Output power level is 5dBm
  516.         ADF4351_Write(adf_data);
  517.         
  518.         
  519.         //配置寄存器3
  520.         adf_data = 0x00848000;        
  521.         /*選擇高頻段(D23=1), APB6ns(D22=0,=建議小數(shù)分頻使用),,(D21=0,小數(shù)分頻使用) 使能CSR(D18=1),(D16 D15=01)快速鎖定
  522.         可修改clock divider value的值*/
  523.         adf_data = adf_data | (adf_Locktime << 3);
  524.         adf_data = adf_data | ADF_R3;        
  525.         ADF4351_Write(adf_data);
  526.         
  527.         //配置寄存器2
  528.         adf_data = 0x61002040;
  529.         //低雜散輸出, 禁用參考倍頻, 二分頻觸發(fā)器使能(減少周跳必須)
  530.         //使能雙緩沖器, 設(shè)置電荷磅電流0.31, 小數(shù)N分頻(40), 設(shè)置R分頻器的值為1
  531.         //設(shè)置鑒相器的極性, (DB6)同向?yàn)V波器1,反向?yàn)V波器0,這里用同向?yàn)V波器
  532.         adf_data = adf_data | (adf_D << 25);
  533.         adf_data = adf_data | (adf_T << 24);
  534.         adf_data = adf_data | (adf_R << 14);        
  535.         adf_data = adf_data | ADF_R2;        
  536.         ADF4351_Write(adf_data);
  537.         
  538.         //配置寄存器1
  539.         adf_data = 0x01008000;
  540.         //禁用相位調(diào)整,預(yù)分頻器的值為8/9
  541.   //相位字為1
  542.         adf_data = adf_data | (adf_PHASE << 15);
  543.         adf_data = adf_data | (adf_MOD << 3);
  544.         adf_data = adf_data | ADF_R1;        
  545.         ADF4351_Write(adf_data);
  546.         
  547.         //配置寄存器0
  548.         adf_data = 0x00000000;
  549.         adf_data = adf_data | (adf_INT << 15);
  550.         adf_data = adf_data | (adf_FARC << 3);
  551.         adf_data= adf_data | ADF_R0;        
  552.         ADF4351_Write(adf_data);
  553.         
  554.         
  555.         
  556.         
  557.         
  558.         
  559. }
復(fù)制代碼

Keil代碼:
ADF4351.rar (297.99 KB, 下載次數(shù): 167)


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:289162 發(fā)表于 2019-7-9 20:33 | 只看該作者
有一個(gè)配置出錯(cuò)了
回復(fù)

使用道具 舉報(bào)

板凳
ID:590434 發(fā)表于 2019-8-3 17:32 | 只看該作者
希望能配置一個(gè)原理圖
回復(fù)

使用道具 舉報(bào)

地板
ID:738095 發(fā)表于 2020-4-26 08:14 | 只看該作者
正好最近用到這款器件
回復(fù)

使用道具 舉報(bào)

5#
ID:882054 發(fā)表于 2021-2-1 13:28 | 只看該作者
正好最近用到這款器件
回復(fù)

使用道具 舉報(bào)

6#
ID:1141167 發(fā)表于 2024-12-25 10:25 | 只看該作者
可以用uart通信嗎
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 欧美在线综合 | 羞羞午夜 | 久久激情网 | 色综合久久伊人 | 中文日本在线 | 国产1区| 国产精品欧美一区二区三区 | 日本精品网站 | 日韩美香港a一级毛片免费 国产综合av | 操操网站 | 夜夜骑天天干 | 欧美精品一区二区三区在线播放 | 91在线一区| 人干人操 | 日本久久久久久久久 | 国产美女精品视频 | 国产精品视频一二三区 | 日韩视频精品在线 | 国产精品久久久久久久模特 | 精品1区 | a国产一区二区免费入口 | 日韩欧美国产一区二区 | 天天躁日日躁狠狠很躁 | 欧美激情视频一区二区三区免费 | 羞羞的视频免费看 | 成人欧美日韩一区二区三区 | 免费一区 | 成人久久久 | 在线观看视频一区二区三区 | 9999国产精品欧美久久久久久 | yeyeav| 九九伦理电影 | 国产高清视频在线观看播放 | 一区精品在线观看 | 亚洲一视频 | 国产不卡一区 | 丁香综合 | 91亚洲国产精品 | 久久久久国产精品 | 91久久| 亚洲高清在线观看 |