EmbDev.net

Forum: µC & Digital Electronics Problem Interfacing ADC AD7856 with LPC2148


Author: Joydeep S. (joydeep_s)
Posted on:

Rate this post
0 useful
not useful
Hello

I am trying to interface external ADC AD7856 with LPC2148. Here goes my 
code
int main(void)
{
  U16 adc_val = 0;
  U8 data = 0;
  U8 upper = 0, lower = 0;
  
 
  HardwareInit();     //SPI and ADC initialised
  AD_7856_SYNC_SET(); // SYNC bit set high
  
  while(1)
  {
   while((AD_7856_BUSY_IOPIN & AD_7856_BUSY));//wait for BUSY bit to set 0
    AD_7856_SYNC_CLR();         // SYNC bit high
    delay(3);
    data = 0xE0;                //Upper MSB write
    SPI_Write(1, &data);
    data = 0xC0;                //lower LSB write
    SPI_Write(1, &data);
    delay(3);
    AD_7856_SYNC_SET();         
    delay(3);
 
  while((AD_7856_BUSY_IOPIN & AD_7856_BUSY));//wait for BUSY bit to set 0
   AD_7856_SYNC_CLR();
   delay(3);
   SPI_Read(&upper);          //Upper MSB read
   adc_val = upper <<8;
   SPI_Read(&lower);          //Lower LSB read
    adc_val = adc_val | lower;
    AD_7856_SYNC_SET();
  }
  return 1;
}


According to the data I can writing I should read back the data as 
0x20C0 but instead the output is always Garbage values.
Moreover the Busy  bit never sets high during conversion it always 
remains low.

Any suggestion is most welcome. And any change in the code required???

Joydeep

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.