⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ad9956.c

📁 直接频率合成器 (DDS)ad9956 单点频功能程序
💻 C
字号:

#include <stdio.h> 
#include <C51.h>

typedef unsigned char uc;

sbit    SCLOCK=P3^1;
sbit    SDI=P3^3;
sbit    SDO=P3^2;
sbit    CSB=P3^5;
sbit    RESET =P3^7;
sbit    IORST=P2^6;
sbit    FUD=P2^0;   		    					
sbit    PS0=P2^1;
sbit	PS1=P2^5;
sbit	PS2=P2^4;

void write1byte(uc byte);
void write5byte(uc addr,uc byte0,uc byte1,uc byte2,uc byte3);
void write6byte(uc addr,uc byte0,uc byte1,uc byte2,uc byte3,uc byte4);
void write9byte(uc addr,uc byte0,uc byte1,uc byte2,uc byte3,uc byte4,uc byte5,uc byte6,uc byte7);
void writeSCBandFUD();
void delay(int);

main()
{		
	RESET=1;							//initialization
	RESET=0;
	IORST=1;
	IORST=0;
	SCLOCK=0;
	PS0=0;
	PS1=0;
	PS2=0;
	SDO=0;
	CSB=1;
	FUD=0;

	/*=================================================================================================================
	单点频模式
	先设置 CFR1  CFR2
	再设频控码至 70MHz
	=================================================================================================================*/
	CSB=0;	
	write5byte(0x00,0x00,0x10,0x00,0x00);				//write cfr1	
	write6byte(0x01,0x00,0x00,0x78,0x00,0x07);			//write cfr2
	write9byte(0x06,0x00,0x00,0x51,0xeb,0x85,0x1e,0xb8,0x52);	//write ftw0	Frequency=70MHz
	CSB=1;

}



void delay(int length)
{
	while (length >=0)
    	length--;
}


void write5byte(uc addr,uc byte0,uc byte1,uc byte2,uc byte3)
{
	write1byte(addr);
	write1byte(byte0);
	write1byte(byte1);
	write1byte(byte2);
	write1byte(byte3);
	writeSCBandFUD();
}

void write6byte(uc addr,uc byte0,uc byte1,uc byte2,uc byte3,uc byte4)
{
	write1byte(addr);
	write1byte(byte0);
	write1byte(byte1);
	write1byte(byte2);
	write1byte(byte3);
	write1byte(byte4);
	writeSCBandFUD();
}

void write9byte(uc addr,uc byte0,uc byte1,uc byte2,uc byte3,uc byte4,uc byte5,uc byte6,uc byte7)
{
	write1byte(addr);
	write1byte(byte0);
	write1byte(byte1);
	write1byte(byte2);
	write1byte(byte3);
	write1byte(byte4);
	write1byte(byte5);
	write1byte(byte6);
	write1byte(byte7);
	writeSCBandFUD();
}

void write1byte(uc byte)
{
	uc temp1;
	int i;
	temp1=0x80;
	CSB=0;
    	SDI=0;                                  

    	for(i=0;i<8;i++)		
    	{
        	if((byte&temp1)==0x0)		
          		SDI=0;
       		else
           		SDI=1;
        	SCLOCK=0;
		delay(10);
        	SCLOCK=1;
		delay(10);
       		SCLOCK=0;
       		temp1=temp1>>1;
    	}	
    	temp1=0x80;
}

void writeSCBandFUD()
{
	CSB=1;		 			
	FUD=0;      		    						
	FUD=1;
	delay(50);
	FUD=0;
	delay(350);
}









⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -