AnsweredAssumed Answered

AD7799 - Communication Issue

Question asked by kunalbajaj23 on Jun 4, 2013
Latest reply on Jun 5, 2013 by ChrisD.Rama

Hi,

 

I'm trying to communicate with the AD7799 IC and I'm facing the following issue.

 

All I'm trying to do is write to the Configuration Register and read back the settings I wrote to it.

 

I'm using an Arduino Pro's SPI BUS  (ATMEGA 328P) 8MHz to talk to it,

 

This is my Code,

 

void setup()

{

  Serial.begin(115200); //Start the Serial Communication at Baud Rate = 115200

   

  SPI.setDataMode(SPI_MODE3); //Clock Idle High and Falling Edge as trigger

  SPI.setClockDivider(SPI_CLOCK_DIV8); //Set Clock Frequency

  SPI.setBitOrder(MSBFIRST);

  pinMode(CS, OUTPUT); // Configuring the chip select pin, D10 as output

  SPI.begin(); // Start the SPI

 

void loop()

{

  if (Serial.available() > 0)

    {

      int inByte = Serial.read();

 

      switch (inByte) {

       case 'w':   

                Serial.println("Writing");

                digitalWrite(CS,LOW); //Drive CS low to initiate communications

                SPI.transfer(0x10); //Writing to Configuration Register

  

                SPI.transfer(0x10); // Unipolar Mode

                SPI.transfer(0x20); // Reference Detect Set High and Gain =1

               

               digitalWrite(CS,HIGH); //Drive CS HIGH to end communications

                break;

        case 'r':   

                Serial.println("Reading");

                digitalWrite(CS,LOW);

                SPI.transfer(0x50); //Instructing Comm Reg to begin Read from the Status Register

                result1 = SPI.transfer(0x50);

                result2 = SPI.transfer(0x50);

               

                digitalWrite(CS,HIGH);

                break;

     

        default:

               break;

      }  

    }

}

 

I initiate a read or write on the serial connection my hitting an 'r' for read and 'w' for write. This is the Kind of output I've been observing,

When I do a Write, 

Screen Shot 2013-06-04 at 5.08.03 PM.png

 

 

When I do a Read I see something weird on the MISO line, This is where I'm stuck

Screen Shot 2013-06-04 at 5.10.41 PM.png

Could someone please help me figure this out?

 

I'm pretty sure my hardware is hooked up right, here's the way I connected the IC,

 

Screen Shot 2013-06-04 at 5.12.25 PM.png

Outcomes