#include <msp430xG43x.h>
#include “DDS_DA
#define uchar unsigned char
#define uint unsigned int
#define DDS_CONTROL_PORT P5OUT
#define DDS_CONTROL_DIR_PORT P5DIR
#define DDS_DA
#define DDS_DA
#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_DA
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_da
for(i=0;i<5;i++)
{
dds_da
SET_DDS_DA
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
}