Hallo, I have the following piece of code to transmit data from the AD7714 to the ATMega8. I always get return values of digital word from the ADC as 255. Can anyone help me out? Thanks Shrishti for(a=0;a<5;a++) { putcharsf("Writing to CR to read from DR\n\r"); SPI_MasterTransmit(0x5C); // Writing to communication register to read from data register SPI_SlaveReceive(); printf("Returned value %d\n\r", dataarray[2]); } // Function to transmit data to master void SPI_MasterTransmit(unsigned char cData) { printf("cDATA Value %X\n\r",cData); SPDR = cData; while(!(SPSR & 0x80)); } unsigned char SPI_SlaveReceive(void) { for(i=0; i < 3 ; i++) { SPDR=0x00; while(!(SPSR & 0x80)); data=SPDR; dataarray[i]=data; printf("i array value %d and data value %d of byte %d\n\r", dataarray[i],data,i); } if(i==3) { return dataarray[2]; } }
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.