#include <STC89C5xRC.H>
#include <stdio.h>
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
void calc();
void pll(unsigned long);
ulong rcdata,nadata,sun,kill;
sbit dt=P2^2;
sbit ck=P2^1;
sbit en=P2^0;
void calc()
{
uchar a,fr; /*VC0输出频率=403.700MHz*/
uint n,r;
r=2560;
n=630;
a=100;
fr=1;//基准频率5KHz,PLL RX状态,d1=l;d2=l;d3=l;d4=h;
rcdata=fr;
rcdata=rcdata<<14;
rcdata=rcdata+r;
rcdata=rcdata<<1;
rcdata=rcdata+1;
nadata=n;
nadata=nadata<<7;
nadata=nadata+a;
nadata=nadata<<1;
}
void pll (ulong kill)/*msb first*/
{
uchar i;
//sun=0x100000;
en=1;
en=0;
for(i=21;i>=0;i--)
{
ck=1;
dt=(bit)(kill & ( 0x01<<i));
//delay();
ck=0;
//delay();
}
ck=1;
en=1;
}
void main(void)
{
while(1)
{
en=1;
ck=1;
dt=0;
calc();
pll(rcdata);
pll(nadata);
}
}
|