多功能调试测试助手-DDS幅度调节AD5620环境说明:CubeSuites+
文件:
r_cg_port_user.c
函数:
unsigned char Write_AD5620(unsigned short regValue)
细列:
// 0 to 4095 for AD5620 (12 bit) //VOUT=2*VrefOUT*(D/4095)
unsigned char Write_AD5620(unsigned short regValue)
{
unsigned char data[2];
unsigned short Value;
Value=regValue<<2;//数据有效宽度:BIT13-BIT2
data[0] = (unsigned char)((Value & 0xFF00) >> 8);//分高8位
data[1] = (unsigned char)((Value & 0x00FF) >> 0);//分低8位
AD5620_CS_L;//片选使能送数据
SPI_Write8(data,2);
AD5620_CS_H;
}
//送8位数据
//unsigned char* data :数据指针
// unsigned char bytesNumber 数据长度
unsigned char SPI_Write8(unsigned char* data, unsigned char bytesNumber)
{
unsigned char i=0,j=0;
//送j个8位数据长度
for(j=0;j
{
for(i=0;i<8;i++)
{
if ((data[j]&0x80)==0x80)
{AD9834_DATA_H;}
else
{AD9834_DATA_L;}
AD9834_SCLK_H;
NOP(); NOP(); NOP(); NOP(); NOP();NOP(); NOP(); NOP(); NOP(); NOP();
AD9834_SCLK_L;
NOP(); NOP(); NOP(); NOP(); NOP();NOP(); NOP(); NOP(); NOP(); NOP();
data[j]<<=1;
}
}
}
输出电压幅度计算
AD9834输出信号幅度VOUT=AD9834满量程电流IFULLSCALE * 负载电阻200(IOUT脚)
AD9834满量程电流IFULLSCALE=18*(AD9834内部基准电压1.20V- AD5620输出电压VDAC)/ 外部电阻RSET(6.8K)
AD5620输出电压VDAC=2*VrefOUT(基准电压2.5V)*(D/4095)