EmbDev.net

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


von Joydeep S. (joydeep_s)


Rate this post
0 useful
not useful
Hello

I am trying to interface external ADC AD7856 with LPC2148. Here goes my 
code
1
int main(void)
2
{
3
  U16 adc_val = 0;
4
  U8 data = 0;
5
  U8 upper = 0, lower = 0;
6
  
7
 
8
  HardwareInit();     //SPI and ADC initialised
9
  AD_7856_SYNC_SET(); // SYNC bit set high
10
  
11
  while(1)
12
  {
13
   while((AD_7856_BUSY_IOPIN & AD_7856_BUSY));//wait for BUSY bit to set 0
14
    AD_7856_SYNC_CLR();         // SYNC bit high
15
    delay(3);
16
    data = 0xE0;                //Upper MSB write
17
    SPI_Write(1, &data);
18
    data = 0xC0;                //lower LSB write
19
    SPI_Write(1, &data);
20
    delay(3);
21
    AD_7856_SYNC_SET();         
22
    delay(3);
23
 
24
  while((AD_7856_BUSY_IOPIN & AD_7856_BUSY));//wait for BUSY bit to set 0
25
   AD_7856_SYNC_CLR();
26
   delay(3);
27
   SPI_Read(&upper);          //Upper MSB read
28
   adc_val = upper <<8;
29
   SPI_Read(&lower);          //Lower LSB read
30
    adc_val = adc_val | lower;
31
    AD_7856_SYNC_SET();
32
  }
33
  return 1;
34
}

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.