AnsweredAssumed Answered

Query AD7982

Question asked by Abhinav on Jul 9, 2011
Latest reply on Jul 28, 2011 by AndyR

Hello Friends,

 

I am using three AD7982 on my board and are interfaced with PIC24HJ256GP610A controller. The mode selected is /CS mode 4-Wire withour busy indication (page 19 of Datasheet)

 

The SDI line of ADC connected to IO pin of Controller and are configured as O/P in code so that ADC can be selected. Rest of the CNV, SCK and SDO line are shared.

 

Can anyone suggest any idea  to make it work. I am getting some data but if I try to probe that data line I dont get correct pricture. And data keeps on fluctuating even when i have shorted the input channel to GND. So I expect almost Zero reading.

 

Abhinav.

 

Ref. Code what I wrote;

 

/*Prior calling this Read ADC function these line are used to initialize*/

/*Default Status for ADC CNV line*/

ADC_CNV = 0;

ADC1_SEL = 1;

ADC2_SEL = 1;

ADC3_SEL = 1;

  

  

void ReadADC(void)

{

UCHAR ucTempADCBuff1 = 0;
UCHAR ucTempADCBuff2 = 0;
UCHAR ucTempADCBuff3 = 0;
UCHAR ucTempADCIndex = 0;
UCHAR ucIndex =0;
/*START of Conversion*/
ADC_CNV  = 1;
DelayMs(1);
while(ucIndex < 3)
{
  switch(ucIndex)
  {
   case 0:  ADC1_SEL = 0;
      asm("NOP");
      break;
   case 1:  ADC2_SEL = 0;
      asm("NOP");
      break;
   case 2:  ADC3_SEL = 0;
      asm("NOP");
      break;
  }
  ucTempADCBuff1 = SPI1TxRx(0xFF);
  ucTempADCBuff2 = SPI1TxRx(0xFF); 
  ucTempADCBuff3 = SPI1TxRx(0xFF);
 
  g_aulnADCBuffer[ucIndex] = g_aulnADCBuffer[ucIndex] | ucTempADCBuff1;
  g_aulnADCBuffer[ucIndex] <<= SHIFT_EIGHT_BITS;
 
  g_aulnADCBuffer[ucIndex] = g_aulnADCBuffer[ucIndex] | ucTempADCBuff2;
  g_aulnADCBuffer[ucIndex] <<= SHIFT_EIGHT_BITS;

  g_aulnADCBuffer[ucIndex] = g_aulnADCBuffer[ucIndex] | ucTempADCBuff3;
//  g_aulnADCBuffer[ucIndex] >>= 6;

  switch(ucIndex)
  {
   case 0:  ADC1_SEL = 1;
      asm("NOP");
      break;
   case 1:  ADC2_SEL = 1;
      asm("NOP");
      break;
   case 2:  ADC3_SEL = 1;
      asm("NOP");
      break;
  }
  ucIndex++;
}
ADC_CNV  = 0;
NOP();
NOP();

}

 

Outcomes