I am working with ATmega32-A micro controller. I am trying to read ADC (AD7798) values. I am setting ADC registers as shown below. Images also attached.
char spi(char data)
{
//Start transmision
SPDR = data;
//Wait for transmision complete
while(!(SPSR & 0x80));
return SPDR;
}
void setupAd(){
ADC_CS=0;
SPCR = 0x5D;
spi(0x10); //set up communication register for configuration reg (16bit).
spi(0x07); // sending 07 as MSB
spi(0x10); //sending 10 as LSB
ADC_CS=1;
}
I am trying to read this configuration setup using this
void ReadAdConfReg(void)
{
SPCR = 0x5D;
ADC_CS=0;
spi(0x50);
adcConfig = spi(0xFF)<<8;
adcConfig |= spi(0xFF);
ADC_CS=1;
}
printing like this
ReadAdConfReg();
printf("configreg:%d",adcConfig);
But my problem setup of that configuration registor was not working. I have checked with oscilloscope any mistakes in clock polarity and chip select. I have attached images as shown below.

Please help me why i am not able to set configuration register. clock polarities and chip select every thing ok according to ATmega32-A data sheet and AD7798 datasheet. please help me what mistake i am doing. or If I want to check my configuration register setup on oscilloscope What i have to do.