Post Go back to editing

AD7799 - Communication Issue

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, 

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

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,

  • Hi kunalbajaj23,

    After power up, perform a reset by applying a series of logic 1's for at least 32 SCLK's-This would ensure that the serial interface is at a known state. After reset, wait for 500us before communicating with the ADC.

    Your write to the configurations register is correct.

    Regarding the read from the configurations register, it is required to write 0x50 to the communications register which would initiate a read from the configurations register. After this, 16 SCLK pulses are applied to the AD7799. There is no need to write 0x50 when the 16 SCLK pulses are being applied. If the DIN line is driven by the uC during the read operation, you should write 0xFF rather than 0x50.

     

    I noticed that you kept CS low between the write and read operations. This is okay, however, if there are glitches on the SCLK line, these glitches may be seen as SCLK pulses that would make the interface lose synchronization. It is recommended to keep DIN high between the read/write operations to make the serial interface more robust.

    Hope this helps.

     

    Thanks and Best Regards,

    Chris