色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > MSP430控制AD9851產(chǎn)生掃頻波

          MSP430控制AD9851產(chǎn)生掃頻波

          作者: 時(shí)間:2016-11-13 來(lái)源:網(wǎng)絡(luò) 收藏
          #include <msp430xG43x.h>

          #include "DDS_DATA.H"
          #define uchar unsigned char
          #define uint unsigned int

          本文引用地址:http://cafeforensic.com/article/201611/316371.htm


          #define DDS_CONTROL_PORT P5OUT
          #define DDS_CONTROL_DIR_PORT P5DIR
          #define DDS_DATA_PORT P4OUT
          #define DDS_DATA_DIR_PORT P4DIR
          #define DDS_FQUD 0x20
          #define DDS_WCLK 0x40
          #define DDS_RESET 0x80

          void SET_DDS_FQUD_HIGH(){DDS_CONTROL_PORT|=DDS_FQUD; };
          void SET_DDS_FQUD_LOW() {DDS_CONTROL_PORT&=~DDS_FQUD;};

          void SET_DDS_WCLK_HIGH(){DDS_CONTROL_PORT|=DDS_WCLK; };
          void SET_DDS_WCLK_LOW() {DDS_CONTROL_PORT&=~DDS_WCLK;};

          void SET_DDS_RESET_HIGH(){DDS_CONTROL_PORT|=DDS_RESET; };
          void SET_DDS_RESET_LOW() {DDS_CONTROL_PORT&=~DDS_RESET;};
          void SET_DDS_DATA(unsigned char lcd_data){ DDS_DATA_DIR_PORT|=0XFF;DDS_DATA_PORT&=lcd_data; };


          void delay1(void)
          {uint m; for(m=11;m>0;m--);}

          void delay(uint z)
          { uint x,y; for(x=z;x>0;x--)for(y=110;y>0;y--);}

          void resetdds(void)
          {
          SET_DDS_RESET_HIGH();
          delay(100);
          SET_DDS_WCLK_LOW() ;
          SET_DDS_FQUD_LOW();
          SET_DDS_RESET_LOW();
          delay(1);
          }

          void DDS_SET_FRE(uint dds_num)
          { uchar dds_data_temp,i;
          for(i=0;i<5;i++)
          {
          dds_data_temp=DDS_DATA[dds_num][i];
          SET_DDS_DATA(dds_data_temp);
          SET_DDS_WCLK_HIGH();_NOP();_NOP();
          SET_DDS_WCLK_LOW() ;_NOP();_NOP();
          }
          SET_DDS_FQUD_HIGH();
          _NOP();_NOP();_NOP();
          SET_DDS_FQUD_LOW();
          }

          void timer0_init()
          {
          CCTL0 = CCIE; // CCR0 interrupt enabled
          CCR0 = 200;
          TACTL = TASSEL_2 + MC_2;
          }

          uint fre_start;
          uint fre_over;
          uint dds_start;
          uint dds_over;
          uchar dds_refresh;
          void main()
          {

          WDTCTL = WDTPW + WDTHOLD;
          timer0_init();
          resetdds();
          fre_start=0;
          fre_over=20;
          dds_refresh=0;
          _BIS_SR(LPM0_bits + GIE);
          }

          // Timer A0 interrupt service routine
          #pragma vector=TIMERA0_VECTOR
          __interrupt void Timer_A (void)
          {
          if(dds_refresh==1)
          {
          dds_refresh=0; //清刷新標(biāo)志
          dds_start=fre_start;
          dds_over =fre_over;
          }
          DDS_SET_FRE(dds_start);
          dds_start=dds_start+1;
          if(dds_start==dds_over){dds_start=fre_start;};
          CCR0 += 200; // Add Offset to CCR0
          }



          關(guān)鍵詞: MSP430控制AD9851掃頻

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉