#include "ad9854.h"
unsigned char table9854[8]
void delay(uint32_t t)
{
unsigned int i=0
while(t--)
for(i=0i<=1000i++)
}
void Port_IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP
GPIO_InitStruct.GPIO_Pin = MASTER_RESET_PORT | IO_UPDATE_PORT | FBH_PORT | RD_PORT | WR_PORT | SHAPED_LEYING_PORT
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE )
GPIO_Init (CTRL_PORT, &GPIO_InitStruct)
GPIO_InitStruct.GPIO_Pin = ADDRESS_PORT | DATA_PORT
GPIO_Init (DAD_PORT, &GPIO_InitStruct)
}
void send_byte(unsigned char add,unsigned char data)
{
WR(1)
delay(2)
ADDRESS(add)
delay(2)
WR(0)
delay(2)
DATA(data)
delay(2)
WR(1)
delay(2)
delay(20)
IO_UPDATE(0)
delay(20)
IO_UPDATE(1)
delay(20)
IO_UPDATE(0)
delay(20)
}
void ad9854_ftw1 (uint64_t f)
{
send_byte(FTW1_6,(((uint64_t)(f*256)/100000000))&(0x0000000000ff))
send_byte(FTW1_5,(((uint64_t)(f*65536)/100000000))&(0x0000000000ff))
send_byte(FTW1_4,(((uint64_t)(f*16777216)/100000000))&(0x0000000000ff))
send_byte(FTW1_3,(((uint64_t)(f*33554432)/1953125))&(0x0000000000ff))
send_byte(FTW1_2,(((uint64_t)(f*2147483648)/1953125))&(0x0000000000ff))
send_byte(FTW1_1,(((uint64_t)(f*549755813888)/1953125))&(0x0000000000ff))
}
/*void ad9854_dfw (void)
{
send_byte(DFW_6,0x00)
send_byte(DFW_5,0x00)
send_byte(DFW_4,0x00)
send_byte(DFW_3,0x0f)
send_byte(DFW_2,0x55)
send_byte(DFW_1,0x55)
send_byte(RRC_3,0xf0)
send_byte(RRC_2,0x10)
send_byte(RRC_1,0xf5)
}
void ad9854_ftw2 (uint64_t f)
{
send_byte(FTW2_6,((uint64_t)((f*256)/280000000))&(0x0000000000ff))
send_byte(FTW2_5,((uint64_t)((f*65536)/280000000))&(0x0000000000ff))
send_byte(FTW2_4,((uint64_t)((f*16777216)/280000000))&(0x0000000000ff))
send_byte(FTW2_3,((uint64_t)((f*4294967296)/280000000))&(0x0000000000ff))
send_byte(FTW2_2,((uint64_t)((f*1099511627776)/280000000))&(0x0000000000ff))
send_byte(FTW2_1,((uint64_t)((f*281474976710656)/280000000))&(0x0000000000ff))
}
*/
void ad9854v(float v)
{
if(v>=1)
{
table9854[6]=0xff
table9854[7]=0xff
}
else
{
table9854[6]=((uint16_t)(v*4096))/256//??
table9854[7]=((uint16_t)(v*4096))%256//???????256
}
send_byte(OSKI_2,table9854[6]) //0~11? 2^12 1V (x/4096)*1=K x=4096k
send_byte(OSKI_1,table9854[7])
send_byte(OSKQ_2,table9854[6])
send_byte(OSKQ_1,table9854[7])
}
void init_9854(void)
{
Port_IO_Init()
MASTER_RESET(0)
delay(200)
MASTER_RESET(1)
delay(200)
MASTER_RESET(0)
delay(2)
send_byte(REFCLK,0x01)
delay(2)
send_byte(MOD,0x02)
delay(2)
send_byte(PD,0x00)
delay(2)
send_byte(OSK_S,0x40)
delay(2)
send_byte(UDCLK_1,0x20)
delay(2)
IO_UPDATE(0)
delay(20)
IO_UPDATE(1)
delay(20)
IO_UPDATE(0)
delay(20)
}
/******************* (C) COPYRIGHT 2012 tc shh *****END OF FILE***************/
#ifndef _AD9854_H_
#define _AD9854_H_
#include "stm32f10x.h"
#define PAR1_H 0x00//Phase Adjust Register#1<13:8>
#define PAR1_L 0X01//Phase Adjust Register#1<7:0>
#define PAR2_H0X02//Phase Adjust Register#2<13:8>
#define PAR2_L0X03//Phase Adjust Register#2<7:0>
#define FTW1_6 0X04//Frequency Tuning Word1<47:40>
#define FTW1_5 0X05//Frequency Tuning Word1<39:32>
#define FTW1_4 0X06//Frequency Tuning Word1<31:24>
#define FTW1_3 0X07//Frequency Tuning Word1<23:16>
#define FTW1_2 0X08//Frequency Tuning Word1<15:8>
#define FTW1_1 0X09//Frequency Tuning Word1<7:0>
#define FTW2_6 0X0A//Frequency Tuning Word2<47:40>
#define FTW2_5 0X0B//Frequency Tuning Word2<39:32>
#define FTW2_4 0X0C//Frequency Tuning Word2<31:24>
#define FTW2_3 0X0D//Frequency Tuning Word2<23:16>
#define FTW2_2 0X0E//Frequency Tuning Word2<15:8>
#define FTW2_1 0X0F//Frequency Tuning Word2<7:0>
#define DFW_60X10//Delta Frequency Word<47:40>
#define DFW_50X11//Delta Frequency Word<39:32>
#define DFW_4 0X12//Delta Frequency Word<31:24>
#define DFW_3 0X13//Delta Frequency Word<23:16>
#define DFW_2 0X14//Delta Frequency Word<15:8>
#define DFW_1 0X15//Delta Frequency Word<7:0>
#define UDCLK_4 0X16//Update Clock<31:24>
#define UDCLK_3 0X17//Update Clock<23:16>
#define UDCLK_2 0X18//Update Clock<15:8>
#define UDCLK_1 0X19//Update Clock<7:0>
#define RRC_3 0X1A//Ramp Rate Clock<19:16>
#define RRC_2 0X1B//Ramp Rate Clock<15:8>
#define RRC_1 0X1C//Ramp Rate Clock<7:0>
#define PD 0X1D//Power Down:DC,DC,DC,Comp PD,0,QDAC PD,DAC PD,DIG PD
#define REFCLK 0X1E//REFCLK:DC,PLL Range,Bypass PLL,RM4,RM3,RM2,RM1,RM0
#define MOD 0X1F//MOD:CLR ACC1,CLR ACC2,Triangle,SRC QDAC,M2,M1,M0,Int Update Clk
#define OSK_S 0X20//OSK&SERIAL COM:DC,Bypass Inv Sinc,OSK EN,OSK INT,DC,DC,LSB First,SDO Active
#define OSKI_2 0X21//Output Shape Key I Mult<11:8>
#define OSKI_1 0X22//Output Shape Key I Mult<7:0>
#define OSKQ_2 0X23//Output Shape Key Q Mult<11:8>
#define OSKQ_1 0X24//Output Shape Key Q Mult<7:0>
#define OSKRR 0X25//Output Shape Key Ramp Rate<7:0>
#define QDAC_2 0X26//QDAC<11:8>
#define QDAC_1 0X27//QDAC<7:0>
#define DAD_PORTGPIOC
#define CTRL_PORT GPIOA
#define ADDRESS_PORTGPIO_Pin_0 |GPIO_Pin_1 |GPIO_Pin_2 |GPIO_Pin_3 |GPIO_Pin_4 |GPIO_Pin_5
#define DATA_PORT GPIO_Pin_6 |GPIO_Pin_7 |GPIO_Pin_8 |GPIO_Pin_9 |GPIO_Pin_10 |GPIO_Pin_11 |GPIO_Pin_12 | GPIO_Pin_13
#define MASTER_RESET_PORT GPIO_Pin_0
#define IO_UPDATE_PORT GPIO_Pin_1
#define FBH_PORTGPIO_Pin_2//fsk/bpsk/hold
#define RD_PORT GPIO_Pin_3
#define WR_PORT GPIO_Pin_4
#define SHAPED_LEYING_PORT GPIO_Pin_5
#define MASTER_RESET(x) x? GPIO_SetBits ( CTRL_PORT , MASTER_RESET_PORT ) : GPIO_ResetBits ( CTRL_PORT , MASTER_RESET_PORT )
#define IO_UPDATE(x) x? GPIO_SetBits ( CTRL_PORT , IO_UPDATE_PORT ) : GPIO_ResetBits ( CTRL_PORT , IO_UPDATE_PORT )
#define FBH(x) x? GPIO_SetBits ( CTRL_PORT , FBH_PORT ) : GPIO_ResetBits ( CTRL_PORT , FBH_PORT )
//#define RD(x) x? GPIO_SetBits ( CTRL_PORT , RD_PORT ) : GPIO_ResetBits ( CTRL_PORT , RD_PORT )
#define WR(x) x? GPIO_SetBits ( CTRL_PORT , WR_PORT ) : GPIO_ResetBits ( CTRL_PORT , WR_PORT )
#define SHAPED_LEYING(x) x? GPIO_SetBits ( CTRL_PORT , SHAPED_LEYING_PORT ) : GPIO_ResetBits ( CTRL_PORT , SHAPED_LEYING_PORT )
#define ADDRESS(x)GPIO_Write (DAD_PORT , ((x&(ADDRESS_PORT)) | (GPIO_ReadOutputData (DAD_PORT) &0xffc0)))
#define DATA(x) GPIO_Write (DAD_PORT , (((x<<6)&(DATA_PORT)) | (GPIO_ReadOutputData (DAD_PORT) &0xc03f)))
void init_9854(void)
void ad9854_ftw1 (uint64_t f)
void delay(uint32_t t)
//void ad9854_ftw2 (uint64_t f)
#endif
/******************* (C) COPYRIGHT 2012 tc shh *****END OF FILE***************/
你的电路肯定有问题。AD9854输出为什么要加电流电压转换电路?标准应该是低通棚昌滤波器才对。
你测得的200mv信号,请留意频率是多少,千万不要是所需信号的2倍频。
后级电路的耦合方式是什么方式?接上后级电路后,电流电压转换输出端的信号就没有了,绝对不是都在内部消耗了,一定是电路有问题,因为实际上你前链态扒面的电流电压转换电路已经起到了缓冲的作用。闭尺
建议你上个电路图来,大家帮你分析一下。
DDS是直接数字式频率合成器DDS(Direct Digital Synthesizer)。
实际上是一种分频器:通过谨搜编程频率控制字来分频系统时钟(SYSTEM CLOCK)以产生所需森握要的频率。
DDS 有两个突出的特点一方面,DDS工作在数字域,一旦更新频率控制字,输出的频率就相应改变,其跳频速率高,另一方面,由于频率控制字的宽度宽(48bit 或者更高),频率分辨率高。
扩展资料:
DDS 有如下优点:
(1) 频率分辨率高,输出频点多,可达个频点(N为相位累加器位数) 。
(2)频率切换速度快,可达us量级。
(3) 频率切换时相位连续。
(4)可以输出宽带正交信号。
(5)输出相位此晌庆噪声低,对参考频率源的相位噪声有改善作用。
(6)可以产生任意波形。
(7)全数字化实现,便于集成,体积小,重量轻。
因此八十年代以来各国都在研制和发展各自的DDS产品,如美国QUALCOMM公司的Q2334、Q2220 、STANFORD公司的STEL-1175、STEL-1180 、AD公司的AD7008,AD9850,AD9854 等。
这些DDS芯片的时钟频率从几十兆赫兹到几百兆赫兹不等,芯片从一般功能到集成有D/A 转换器和正交调制器。
DDS除了用于跳频系统中外,还可以用于任意波形产生、信号调制等,随着高速集成电路的飞速发展,DDS 必将开拓更多新的应用领域。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)