Q: How to write a driver in C code for the AD7705 I want to run AD7705 by ATMEGA8 microcontroller and I used the following C.code:
`
DDRB = 0x6e;     //PinB.1(DRDY')=output , PinB.2(SS')=output , PinB.3(MOSI) = output , PinB.4(MISO)=input , PinB.5(SCK)=output , PinB.6(Reset') = output
PORTB = 0x91;//outputs=0 & inputs= pullup

if (EXTRF == 1) {PORTB.6=0;delay_ms(1);}//Reset the ADC with Reseting the micro

SPCR = 0x70;//SPI Enabled, MSB Data Order, Master, Sampling by Rising Edge, SCKF=fosc/4

SPSR = 0x00;

//Serially reset the Chip 
for (j = 0; j < 5; j++)
{
    SPDR = 0xff;
    delay_ms(10);
}
while(!(SPSR & (1<<SPIF)));//wait for transfer

SPDR = 0b00100000;//Send to Comm Reg: Next Write Clk =0x20
while(!(SPSR & (1<<SPIF)));//wait for transfer

SPDR = 0b00000100;//Send to ClkReg: Clock Bits and Update rate =0x04 ->CLKDIV=0,CLK=1,Filter Selection=00(output update rate = 50Hz)
while(!(SPSR & (1<<SPIF)));//Wait for transfer 

SPDR = 0b00010000;//Send to Comm Reg: Next Write Setup reg =0x10 
while(!(SPSR & (1<<SPIF)));//Wait for transfer

// set setup register: Self Calibration Mode,gain=1,
// unipolar operation,buffer enabled,
// filter synchronization in set state =0x06
SPDR = 0b01000110;
while(!(SPSR & (1<<SPIF)));//Wait for transfer

SPDR = 0b00001000;//Send to Comm: next read Comm reg =0x08 
while(!(SPSR & (1<<SPIF)));//Wait for transfer        

SPDR = 0b00111000;//Send to Comm: next read Data reg =0x38 MS-Byte
while(!(SPSR & (1<<SPIF)));//Wait for transfer

read = SPDR;

SPDR = 0b00111000;//send to Comm: next read Data reg =0x38 LS-Byte
while(!(SPSR & (1<<SPIF)));//Wait for transfer

read <<= 8//shift to MS-Byte of int read
read = read|SPDR;// make 16 bit data
read2 = read;    
read2 = (read2*2.5)/65535;
ftoa(read2,6,str);
lcd_gotoxy(0,1);
lcd_puts("V=");
lcd_gotoxy(2,1);
lcd_puts(str);

my problem is that in output I always get constant number(2.00 or 2.22)! I don't know what should I change to get correct output.
as reference voltage I put 2.5 V and to power up the AD7705 I put 3 V.
gain=1,update rate=50 Hz, channel 1, Uni polar, clock=2.4576 MHz 
AD7705 with ATMEGA8A
