#include"reg52.h"
#define uchar unsigned char
sbit clk = P0^2;
sbit load = P0^3;
sbit dat = P0^4;
void init_dds(void)
{
clk=0;
load=0;
clk=1;
clk=0;
load=1;
load=0;
}
void write_dds(unsigned long dds)
{
uchar i;
load=0;
clk=0;
for(i=0;i<40;i++)
{
clk=0;
if(dds & 0x00000001)
dat=1;
else dat=0;
clk=1;
dds=dds>>1;
}
load=1;
clk=0;
load=0;
}
void write_freq(unsigned long freq)
{
unsigned long dds;
dds=34.35943*freq;
write_dds(dds);
}
void main()
{
init_dds();
write_freq(500000);
write_freq(500000);
while(1)
{
}
}