AnsweredAssumed Answered

AD7190 - Comms issue regarding LSB allways 1

Question asked by ElectronAby on May 15, 2012
Latest reply on May 15, 2012 by MaryMc

Hi all,

 

I have same problem regarding the reading of the RDY signal being read back as a 1 for the LSB of the data. Im running in continous read mode with DAT_STA set to 1 so that my final byte gives the STATUS data. Of course my conversion data is correct but im allways getting a 1 as the LSB of the STATUS data. I am bit-banging the data into my microcontroller. Can you please assist with the code as im getting a little confused: My read code is shown below: What am i doing wrong? Plaese help.

 

============================================================================

unsigned char uci;

unsigned long ulRecievedData = 0;

 

SCLK_HI; 
Delay(PULSETIME);                       

 

  if(ucWaitRDY)       /* if need to check DOUT/RDY pin is low */
  {
    while ((P4IN & AD7190_SOMI_RDY_PIN) == AD7190_SOMI_RDY_PIN) /* While DOUT/RDY pin is high */
    {
      ;               /* Just sit and wait........... */
    };                /* ....until DOUT/RDY pin is low */
  }
 

  for(uci=0;uci<=(ucDataBitLength-1);uci++)  /* for ucDataBitLength iterations (this is 32) */
  {

    if(P4IN & AD7190_SOMI_RDY_PIN)          /* If bit is a '1' */
    {
      ulRecievedData++;                     /* add 1 to data in else '0' will be added by default */
    }
    SCLK_LO;                                /* Clock low (falling edge created) */
    Delay(PULSETIME);                        
    SCLK_HI;                                /* Clock high (rising edge created) */
    Delay(PULSETIME);                        
    ulRecievedData = ulRecievedData << 1;   /* shift data left */

  }

 

  if(P4IN & AD7190_SOMI_RDY_PIN)            /* if last bit is a '1' */
  {
    ulRecievedData++;                       /* add 1 to data in else '0' will be added by default */
  }
  

  SCLK_HI;                                  /* Clock idle high */
 

  return ulRecievedData;                    /* return recieved data */

 

===================================================================================

 

Where am i going wrong? Any help will be appreciated. Thankyou.

Outcomes