unsigned int adnum=1;
unsigned char dnum=0;
union ad_cmd
{
unsigned int adint; // adint = adchar[1]+adchar[0]
unsigned char adchar[2];
};
union ad_cmd adcmd1;
unsigned int maskint= 0xC3F0; //0b1100 0011 1111
// --c--
adcmd1.adint = 0x8330; //0b1000 0011 0111 0000
adnum=0;
dnum=0;
do
{
adcmd1.adint &= maskint;
adcmd1.adint |= (adnum<<10); //Shifted for 10time
SPDR = adcmd1.adchar[1];
while(!(SPSR & (1<<SPIF))); // wait until transmission is complete
SPDR = adcmd1.adchar[0];
while(!(SPSR & (1<<SPIF))); // wait until transmission is complete
_delay_ms(10);
SPDR = 0x03;
while(!(SPSR & (1<<SPIF))); // wait until transmission is complete
ad7490_data[dnum]= SPDR;
dnum++;
SPDR = 0x30;
while(!(SPSR & (1<<SPIF))); // wait until transmission is complete
ad7490_data[dnum]= SPDR;
adnum++;
dnum++;
}while (adnum < 16);