To computer00,
我最近在用AD5934的时候发现不能连续的进行每个频率点的测量(我是用仿真器仿真的),第一个频率点的测量没有问题(就是初始化之后,读寄存器0x8F的D1位,等D1位为1时,说明转换结束,读出实部与虚部值,第一次都是好的),但是等到下一个频率点的时候(就是对寄存器0x80写入 increment frequency的命令),发现很长时间读寄存器0x8F的D1位一直是0,如果把断点打在“读出实部值处”,程序会一直死在那里,但如果单步的执行“ while( !(AD5933_ReadByte(dAD5933StatusReg8F) & 0x02)); ”,执行几次以后,发现继续向下走了,而且能读到实部和虚部的值!希望大家都帮我看看, 最近一直为这事郁闷呢!我的AD5934 测试部分和初始化的程序如下(程序里面用的名字是AD5933,但我实际用的是AD5934):
void AD5933_Measure( void ) {
//测试 150 points
while(!(AD5933_ReadByte(dAD5933StatusReg8F) & 0x04)) //判断整个频率扫描结束
{
while( !(AD5933_ReadByte(dAD5933StatusReg8F) & 0x02)); //等待第一个频率点转换结束
kAD5933_GetValue.rRealPartValue.rRealPartL = AD5933_ReadByte(dAD5933RealPartReg95); //读出实部值 kAD5933_GetValue.rRealPartValue.rRealPartH = AD5933_ReadByte(dAD5933RealPartReg94);
//read the Imaginarypart of impedance kAD5933_GetValue.rImaginaryPartValue.rImaginaryPartL = AD5933_ReadByte(dAD5933ImaginaryPartReg97); //读出虚部值 kAD5933_GetValue.rImaginaryPartValue.rImaginaryPartH = AD5933_ReadByte(dAD5933ImaginaryPartReg96);
AD5933_WriteByte( dAD5933ControlReg80, dInitControlReg80IncrementFreq ); // increment 频率点
}
} void AD5933_Init( void ) { AD5933_WriteByte( dAD5933StartFreqReg82, dInitStartFreqReg82 ); //4.9152Mhz, 30k start freq AD5933_WriteByte( dAD5933StartFreqReg83, dInitStartFreqReg83 ); AD5933_WriteByte( dAD5933StartFreqReg84, dInitStartFreqReg84 ); AD5933_WriteByte( dAD5933IncrementNumReg88, dInitIncrementNumberReg88 ); //number Increment, 150 AD5933_WriteByte( dAD5933IncrementNumReg89, dInitIncrementNumberReg89 ); AD5933_WriteByte( dAD5933FreqIncrementReg85, dInitFreqIncrementReg85 ); //Increment Freq, 10Hz AD5933_WriteByte( dAD5933FreqIncrementReg86, dInitFreqIncrementReg86 ); AD5933_WriteByte( dAD5933FreqIncrementReg87, dInitFreqIncrementReg87 ); AD5933_WriteByte( dAD5933TimeCyclesReg8A, dInitTimeCyclesReg8A ); //15 time cycles AD5933_WriteByte( dAD5933TimeCyclesReg8B, dInitTimeCyclesReg8B ); // AD5933_WriteByte( dAD5933ControlReg80, dInitControlReg80Standby ); //set AD5933 Standyby Mode AD5933_WriteByte( dAD5933ControlReg81, dInitControlReg81ExternalOsc ); //set Internal/External Osc AD5933_WriteByte( dAD5933ControlReg80, dInitControlReg80Range_PGA ); //Set PGA = x1, excitation range 2v p-p AD5933_WriteByte( dAD5933ControlReg80, dInitControlReg80InitWithFeg ); //Initialize with start frequency AD5933_StartFreqSweep(); }
|