7706寄存器读写和初始化程序如下:
unsigned char read_7706()
{
unsigned char dat;
RI=0;
while(RI==0);
dat=SBUF;
return dat;
}
void write_7706(unsigned char dat)
{
TI=0;
SBUF=dat;
while(TI==0);
TI=0;
}
/*;*** AD7706 ANALOGUE TO DIGITAL CONVERTOR CONFIGURATION
*********************************
;
;This is the AD7706 configuration routine
;
;The ADC configuration steps are as follows:
; 1)Write to the communications register specifying that the next operation to
be a
; write to the clock register,select AIN1 (ie 0x20).
;
; 2)Write to the clock register appropiate settings (ie 0x0C)
; - Mclk out enabled
; - Input clock divided by two
; - Update rate of 20 ms or 50 Hz which gives
; a 3 dB digital filter cutoff of 13.1 Hz
;
; 3)Write to the comms register specifying that the next operation to be a
write to
; the setup register and a calibration on channel 3 (ie 0x13)
;
; 4)Write to the setup register appropiate settings (0x54)
; - perform self calibration on channel 3
; - Gain of 4 (max input voltage 0.625 !!)
; - unipolar mode
; - on chip buffer enabled
; - clear Fsync to begin a conversion
*/
void init_7706()
{
write_7706(0x20); //1.write communication reg,next write clock reg
write_7706(0x0C); //2.write clock reg,
write_7706(0x08); //.write communication register,next read communication
register
temp=read_7706(); //read communication register
write_7706(0x28); //next read clock register
temp=read_7706(); //read clock register
write_7706(0x10); //3.write communication register,next write set register
write_7706(0x40); //4.write set register
write_7706(0x08); //next read communication register
temp=read_7706(); //read communication register
write_7706(0x18); //next read set register
temp=read_7706(); //read set register
}
发现读出的寄存器值均为0xff,初始化不成功的。软硬件和资料是符合的啊,怎么会有这么
奇怪的问题呢???