有谁用过AD7190作为测压力的电压啊?我是软件新手,刚开始学写程序,我从ADI官网上下了一个AD7190的初始化程序,再根据我的电路对配置寄存器做了一定的修改,结果发现AD转换后得到的数据始终为0,这时怎么回事啊。初始化源码见下:
void LC_Init(void)
{
CPU_CS0_ADC = 0;
nops();
buf[2] = 0xff;
buf[1] = 0xff;
buf[0] = 0xff;
WriteToAD7190(3,buf); //Reset AD7190 CHIP.
buf[1] = 0xff;
buf[0] = 0xff;
WriteToAD7190(2,buf); //Reset AD7190 CHIP.
/* buf[0] = 0x40;
WriteToAD7190(1,buf); //write communication register 0x50 to control the progress to read state register
ReadFromAD7190(3,buf); //read state register
*/
// Configuration register
buf[0] = 0x10;
WriteToAD7190(1,buf); //write communication register(8-bits) 0x10 to control the progress to write configuration register
buf[2] = 0x00;
buf[1] = 0x01;
buf[0] = 0x5f; //enable to check Vrefin.enable the buffer.
WriteToAD7190(3,buf); //write configuration register:disable chop,unipolar operation,gain=128,channel:AIN1 to AIN2
// mode register(Internal zero calibration)
buf[0] = 0x08;
WriteToAD7190(1,buf); //write communication register 0x08 to control the progress to write mode register
buf[2] = 0x94; //enable transfor the data of status register and enable external 4.92MHz clock.
buf[1] = 0x03; //select to Continuous Conversion mode
buf[0] = 0xFF;
WriteToAD7190(3,buf); //write mode register,external 4.92MHz clock,output data rate=4.7Hz
// mode register(Internal full scale calibration)
buf[0] = 0x08;
WriteToAD7190(1,buf); //write communication register 0x08 to control the progress to write mode register
buf[2] = 0xB4; //enable transfor the data of status register and enable external 4.92MHz clock.
buf[1] = 0x03; //select to Continuous Conversion mode
buf[0] = 0xFF;
WriteToAD7190(3,buf); //write mode register,external 4.92MHz clock,output data rate=4.7Hz
// mode register
buf[0] = 0x08;
WriteToAD7190(1,buf); //write communication register 0x08 to control the progress to write mode register
buf[2] = 0x14; //enable transfor the data of status register and enable external 4.92MHz clock.
buf[1] = 0x03; //select to Continuous Conversion mode
buf[0] = 0xFF;
WriteToAD7190(3,buf); //write mode register,external 4.92MHz clock,output data rate=4.7Hz
// read ID register
buf[0] = 0x64;
WriteToAD7190(1,buf); //write communication register 0x64 to control the progress to read ID register
ReadFromAD7190(1,buf); //read ID register
// read data register
buf[0] = 0x5A; //enable Continuous transformation format
WriteToAD7190(1,buf); //write communication register 0x58 to control the progress to read data register
ReadFromAD7190(3,buf); //read data register
CPU_CS0_ADC = 1;
return;
} |