I do have the source. Written in ICCv5 or ICCv6 for the AVR. The code for the init of the AD7731 is very similar. (
I have even tried the exact settings although we are not using all the same inputs).
I am using MikroC Pro for the PIC.
The signal out on the working system (Old units) is different in that the AD7731 actually responds and takes readings then sets the Data Ready Pin LOW.
I captured the signals, adjusted my program to be identical and still nothing.
After some suggestions from Analog Devices Support, I created an arduino sketch that cycles through all 4 SPI modes and, resets (sends 32 1's) the AD7731 and sets to continuous conversion mode.
According to them, this should reset the device and make the device enter normal conversion and start cycling the Data Ready pin at normal intervals.
Although, its still not working...
Here is the arduino code.
// include the SPI library:
#include <SPI.h>
// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;
int dataReadyPin = 9;
void setup() {
// set the slaveSelectPin as an output:
pinMode (slaveSelectPin, OUTPUT);
pinMode (dataReadyPin, INPUT );
// initialize SPI:
SPI.begin();
}
void setupADC(void){
// reset ADC
// reset ADC
digitalWrite(slaveSelectPin, LOW);
SPI.transfer(0xff);
SPI.transfer(0xff);
SPI.transfer(0xff);
SPI.transfer(0xff);
//SPI.transfer(0xff);
digitalWrite(slaveSelectPin, HIGH);
digitalWrite(slaveSelectPin, LOW);
SPI.transfer(0x02);
SPI.transfer(0x31);
SPI.transfer(0xf4);
digitalWrite(slaveSelectPin, HIGH);
delay(100);
}
void loop() {
SPI.setDataMode(SPI_MODE0);
setupADC();
SPI.setDataMode(SPI_MODE1);
setupADC();
SPI.setDataMode(SPI_MODE2);
setupADC();
SPI.setDataMode(SPI_MODE3);
setupADC();
}
The device is wired up as follows on the breadboard.
Pin1 to Arduino Pin 13 (SCK)
Pin 2 to 4Mhz crystal with 22pf cap
Pin 3 to 4Mhz crystal with 22pf cap
pin 4 to GND
pin 5 to vcc (+5v from arduino)
pin 6 to vcc (+5v from arduino)
pin 8 to GND
pin 9 to vcc (+5v from arduino)
Pins 10 - 13 are floating
pin 14 to vcc (+5v from arduino)
pin 15 to GND
pins 16 and 17 floating
pin 18 to vcc (+5v from arduino)
pin 19 to Arduino pin 10 (SlaveSelect)
pin 20 to Arduino pin 9 (DataReady)
pin 21 to Arduino pin 12 (MISO)
pin 22 to Arduino pin 11 (MOSI)
pin 23 to vcc (+5v from arduino)
pin 24 to GND
After looping through all 4 SPI modes and pausing for 100ms in between each mode, the Data Ready Pin never changes from a HIGH state as measured by my Saleae Logic 8.
I see there are 3 possible scenarios here:
1. I am a moron and cannot see what I am doing wrong...
2. I destroyed the devices somehow... (Most likely)
3. I received 2 bad DIP samples. (Not likely)
I have 2 additional SOIC AD7731 devices. I have ordered SOIC socket to DIP adapters so that I can test with these devices without soldering them to adapters.