AD7780 SPI compatible communication

Hi! I'm trying to read a loadcell, but i've got no idea what's wrong with my code. Maybe i fryied the chip, but i dont get any good result. Not even the constant status byte. When the A/D finish a conversion, it pull the DOUT pin(MISO) to the ground. Then we can shift out 32 bit. Please help me. Thanks in advance!

datasheet: http://www.farnell.com/datasheets/608920.pdf SPI: http://arduino.cc/en/Reference/SPI clock polarity and phase: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus#Clock_polarity_and_phase

my code:

void loop() { while(digitalRead(12)==HIGH); // MISO SPI.begin(); SPI.setClockDivider(SPI_CLOCK_DIV16); // 1 MHz SPI.setBitOrder(MSBFIRST); SPI.setDataMode(SPI_MODE3); //CPOL=1 the base value of the clock is one //CPHA=1 data are captured on clock's rising edge and data are propagated on a falling edge. spia=SPI.transfer(0); //byte spib=SPI.transfer(0); spic=SPI.transfer(0); spid=SPI.transfer(0); SPI.end();

"10 ms program" }

How do you know it's not working, I don't see any output.

I don't think you need to init the SPI every time although I'm not sure it would do any harm, I'd try this

void setup (void) {

  Serial.bnegin(115200);
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV16);  // 1 MHz
  SPI.setBitOrder(MSBFIRST); 
  SPI.setDataMode(SPI_MODE3);       //CPOL=1 the base value of the clock is one
                                    //CPHA=1 data are captured on clock's rising edge 
                                    //and data are propagated on a falling edge.
}


void loop() {
  while(digitalRead(12)==HIGH);       // MISO          

  spia=SPI.transfer(0);                   //byte
  spib=SPI.transfer(0);
  spic=SPI.transfer(0); 
  spid=SPI.transfer(0);

  Serial.print (spia, HEX);  
  Serial.print (spib, HEX);  
  Serial.print (spic, HEX);  
  Serial.println (spid, HEX);  

}

You really should also test for a falling edge on MISO but as the ADC is so slow it shouldn't matter for the time being as long as the Serial bit rate is kept at a high rate.


Rob

I send the bytes through an infra link, then print on the screen with another arduino. That part is working. I've tried what you said and still don't work. Anyway, thanks.

It is always the thing that you know is right that is wrong. Why are you bothering with an IR link when you can just serial print? Your results would suggest an error with the total number of clock pulses.

I want to measure torque on a rotating shaft. That's why i need the IR and the second Arduino.

Ir is working as intended. I tested it.