您好,看了您这篇关于AD9102应用的帖子。我现在也在调试这个片子,目前SPI读写正常,SRAM写入读出也正常,预存波形输出正常,但是没法输出SRAM里面设定的波形。求助一下大神, 能不能帮忙看看问题在哪。我的QQ:344135324(CC)。感激不尽。代码如下。
/**************************************/
#define SRAM_START_ADDRESS 0x000
#define SRAM_STOP_ADDRESS 0xF9f //4000 samples
/************AD9102 Reg****************/
#define AD9102_SPICONFIG 0x0000
#define AD9102_POWERCONFIG 0x0001
#define AD9102_CLOCKCONFIG 0x0002
#define AD9102_REFADJ 0x0003
#define AD9102_DACAGAIN 0x0007
#define AD9102_DACRANGE 0x0008
#define AD9102_DACRSET 0x000C
#define AD9102_CALCONFIG 0x000D
#define AD9102_COMPOFFSET 0x000E
#define AD9102_RAMUPDATE 0x001D
#define UPDATE 0x01
#define AD9102_PAT_STATUS 0x001E
#define BUF_READ (0x01<<3)+(0x01<<2)
#define MEM_ACCESS (0x01<<2)
#define RUN (0x01)
#define AD9102_PAT_TYPE 0x001F
#define AD9102_PATTERN_DLY 0x0020
#define AD9102_DACDOF 0x0025
#define AD9102_WAV_CONFIG 0x0027
#define AD9102_PAT_TIMEBASE 0x0028
#define AD9102_PAT_PERIOD 0x0029//0x3F=63-->about 62.5KHz
#define AD9102_DAC_PAT 0x002B
#define AD9102_DOUT_START 0x002C
#define AD9102_DOUT_CONFIG 0x002D
#define AD9102_DAC_CST 0x0031
#define AD9102_DAC_DGAIN 0x0035//0x4000
#define AD9102_SAW_CONFIG 0x0037
#define AD9102_DDS_TW32 0x003E
#define AD9102_DDS_TW1 0x003F
#define AD9102_DDS_PW 0x0043
#define AD9102_TRIG_TW_SEL 0x0044
#define AD9102_DDS_CONFIG 0x0045
#define AD9102_TW_RAM_CONFIG 0x0047
#define AD9102_START_DELAY 0x005C
#define AD9102_START_ADDR 0x005D
#define AD9102_STOP_ADDR 0x005E
#define AD9102_DDS_CYC 0x005F
#define AD9102_CFG_ERROR 0x0060
#define AD9102_SRAM_DATA 0x6000
/**************************************/
void Ad9102_Init2(void)
{
uint32_t i = 0;
uint32_t ui_AD9102SramAddr = 0;
int16_t data;
Soft_Spi_Init();
Gpio_Output_Pp_Init(TRIGGER,GPIO_PIN_SET);
Gpio_Output_Pp_Init(NRESET,GPIO_PIN_RESET);
delay_ms(5);
Gpio_Set(NRESET);
delay_ms(1);
Ad9102_Write(AD9102_PAT_STATUS,MEM_ACCESS);
for(i = 0; i < 4000; i++)
{
ui_AD9102SramAddr = AD9102_SRAM_DATA+(i<<0);
Ad9102_Write(ui_AD9102SramAddr,AD9102SRAM<<2);
}
delay_ms(5);
Ad9102_Write(AD9102_PAT_STATUS,BUF_READ);
for(i = 0; i < 4000; i++)
{
ui_AD9102SramAddr = AD9102_SRAM_DATA+(i<<0);
data = Ad9102_Read(ui_AD9102SramAddr);
printf("\r\n data[%d] = %d",i,data>>2);
}
//Step2:Set AD9102 Register
Ad9102_Write(AD9102_PAT_PERIOD,0x003f);
Ad9102_Write(AD9102_PAT_TYPE,0x0000);//以连续模式运行
Ad9102_Write(AD9102_DACRSET,0x9f1F);
Ad9102_Write(AD9102_WAV_CONFIG,0x0030);
// Ad9102_Write(AD9102_SAW_CONFIG,0x00FC); //锯齿波配置寄存器..
Ad9102_Write(AD9102_DAC_DGAIN,0x4000); //DAC数字增益
Ad9102_Write(AD9102_DDS_TW32,0x006C); //..
Ad9102_Write(AD9102_DDS_TW1,0xE600); //..
Ad9102_Write(AD9102_START_DELAY,0);
Ad9102_Write(AD9102_START_ADDR,SRAM_START_ADDRESS);
Ad9102_Write(AD9102_STOP_ADDR,(SRAM_STOP_ADDRESS << 4));
Ad9102_Write(AD9102_PAT_STATUS,RUN);
Ad9102_Write(AD9102_RAMUPDATE,UPDATE);
delay_ms(10);
data = Ad9102_Read(AD9102_PAT_TYPE);
printf("\r\n AD9102_PAT_TYPE:0x%4.4x",data);
data = Ad9102_Read(AD9102_DACRSET);
printf("\r\n AD9102_DACRSET:0x%4.4x",data);
data = Ad9102_Read(AD9102_WAV_CONFIG);
printf("\r\n AD9102_WAV_CONFIG:0x%4.4x",data);
data = Ad9102_Read(AD9102_SAW_CONFIG); //锯齿波配置寄存器
printf("\r\n AD9102_SAW_CONFIG:0x%4.4x",data);
data = Ad9102_Read(AD9102_DAC_DGAIN); //
printf("\r\n AD9102_DAC_DGAIN:0x%4.4x",data);
data = Ad9102_Read(AD9102_DDS_TW32); //
printf("\r\n AD9102_DDS_TW32:0x%4.4x",data);
data = Ad9102_Read(AD9102_DDS_TW1); //
printf("\r\n AD9102_DDS_TW1:0x%4.4x",data);
data = Ad9102_Read(AD9102_PAT_STATUS); //
printf("\r\n AD9102_PAT_STATUS:0x%4.4x",data);
data = Ad9102_Read(AD9102_RAMUPDATE); //
printf("\r\n AD9102_RAMUPDATE:0x%4.4x",data);
data = Ad9102_Read(AD9102_CFG_ERROR); //
printf("\r\n AD9102_CFG_ERROR:0x%4.4x",data);
Gpio_Reset(TRIGGER);
delay_ms(10);
Ad9102_Write(AD9102_RAMUPDATE,UPDATE);
Ad9102_Write(AD9102_DACRSET,0x9f1F);
}