EmbDev.net

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


von Joydeep S. (joydeep_s)


Rate this post
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.