您的位置 首页 分销

MSP430操控AD9851发生扫频波

#includemsp430xG43x.h>#includeDDS_DATA.H#defineucharunsignedchar#defineuintunsignedint#defineDDS_

#include <msp430xG43x.h>

#include “DDS_DATA.H”
#define uchar unsigned char
#define uint unsigned int

#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; //清改写标志
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
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/fenxiao/272904.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部