How do i get correct output from ADC AD7714 with XBEE 900HP

we are trying to interface a programmable XBEE to the ADC, AD7714YN, but we are getting the same variables no matter what voltage we give into the ADC.

Din is connected to MOSI of XBEE

Dout is connected to MISO of XBEE

We are using an input voltage from the XBEE connected to the USB (~3.3Volts)

We connected Dready of ADC to GPIO of XBEE

#include 
#include 
 
#define BUFLEN_C    1
#define BUFLEN_D    3
 
uint8_t txbuf; //transit buffer
uint8_t rxbuf[BUFLEN_D]; //receive buffer
uint8_t dummybuf[BUFLEN_D]; //Buffer with dummy values
bool_t Flag = 0; //Real time clock flag: will be changed to real time later
 
void ADC_SPI(void);
void delay(int num);
 
void delay(int num)
{
    int j;
    int k;
    for(j=0;j<=num;j++){
     while(k<256){
         k++;
     }
    k=0;    
    }
}
 
void ADC_SPI(void)
{
    uint32_t value = 0;
    int i;
    printf("
Commence Setup");
    dummybuf[0] = 0xFF;
    dummybuf[1] = 0xFF;
    dummybuf[2] = 0xFF;
    rxbuf[0] = 0xFF;
    rxbuf[1] = 0xFF;
    rxbuf[2] = 0xFF;
    txbuf = (uint8_t)32; //0x20 set comm reg to write to high filter reg
    (void)spi_transfer(0,txbuf,NULL,BUFLEN_C);
    delay(100);
    txbuf = (uint8_t)64; //0x40 set high fil reg so 24bits and no filter
    (void)spi_transfer(0,txbuf,NULL,BUFLEN_C);
    delay(100);
    txbuf = (uint8_t)48; //0x30 set comm reg to write to low filter reg
    (void)spi_transfer(0,txbuf,NULL,BUFLEN_C);
    delay(100);
    txbuf = (uint8_t)0; //0x00 set low fil reg so there is no filter
    (void)spi_transfer(0,txbuf,NULL,BUFLEN_C);
    delay(100);
    txbuf = (uint8_t)16; //0x10 set comm reg to write to mode reg
    (void)spi_transfer(0,txbuf,NULL,BUFLEN_C);
    delay(100);
    txbuf = (uint8_t)0; //0x00 set mode reg for normal mode no gain
    (void)spi_transfer(0,txbuf,NULL,BUFLEN_C);
    delay(100);
    printf("
Finish Setup
Waiting for DRDY to go LOW...");
    for(;;){
    if ((gpio_get(XPIN_7))==0){    
     printf("
DRDY is LOW!");
     txbuf= (uint8_t)88; //0x58 set comm reg to read from data reg and at Ain 1/6
     (void)spi_transfer(0,txbuf,NULL,BUFLEN_C);    
     delay(100);
     (void)spi_transfer(0,dummybuf,rxbuf, BUFLEN_D); //read
     delay(100);
     printf("
");
     for (i = 0; i < BUFLEN_D; i++) {
         printf("%d", rxbuf[i]);
         
     }
     return;    
    }
    }
}
 
#if defined(RTC_ENABLE_PERIODIC_TASK)
void rtc_periodic_task(void)
{
   Flag = 1;
}
#endif
 
void main(void)
{
    int count = 1;
    sys_hw_init();
    sys_xbee_init();
    sys_app_banner();
    
    printf("
Starting");    
    for (;;) {
     if(Flag ==1 ){
         printf("
ADC Selected %d times",count);
         count++;
         ADC_SPI();
         printf("
Done");
         Flag = 0;
     }    
     delay_ticks(HZ);
     sys_watchdog_reset();
     sys_xbee_tick();                
    }        
}

You would need to connect the AD7714YN to the SPI bus of the XBee 900 HP module. You would also need to create the necessary code on the AD7714YN to send our API frames.

We are trying to get the freescale processor on the programmable XBee to work with SPI.
The examples have given us this function to use (from SPI.h library) :
(void)spi_transfer(0,txbuf,rxbuf, BUFLEN)
Pin 18 : SPI clock
Pin 4 : MISO
Pin 11: MOSI

However, we are not getting any outputs from the XBee including the SPI clock.

Thanks!

The SPI port of the Freescale processor is for external communications. It does not connect to the RF processor. You do need to issue 0xFF’s to get data from the SPI port.