Go Down

Topic: SPI Iterfacing AD7175  (Read 1 time) previous topic - next topic

bob4i

Nov 30, 2014, 04:49 pm Last Edit: Nov 30, 2014, 05:14 pm by bob4i
Hello,
I want to communicate with AD7175 24bit ADC, but the RDY signal is attached to MISO. Can I use pin define
#define MISO 74;
and then to use pinMode(MISO, INPUT);
or to separate the DOUT/RDY signal once to MISO and once to additional pin of due and monitor it on this pin.
I have to catch the low level of MISO (DOUT/RDY pin of AD7175). Is there any other way to catch the MISO low level ( not interrupt one ) ?

MorganS

Well, I doubt that the manufacturer would design the chip in a way that makes it impossible for most microcontrollers to talk to it.

Before I start, I will say that most of the SPI work I have done is with the AVR Arduinos, not on the Due, so there may be some critical difference. You will need to test this.

The MISO pin can be used like any other INPUT pin. When you do SPI.begin() it will be configured as an input. Just don't change it to an output as that will probably give the SPI a problem. You can mix digitalRead(MISO) with SPI functions. If you're really pushing the SPI and trying to make it asynchronous (use a send queue while your program does other things) then you may run into trouble trying to sample the input while SPI is part-way through a byte. The standard Arduino functions are synchronous, so you will not have any problem with that.

Reading the datasheet for the AD7175, it looks like the correct way of using it is:

Code: [Select]
digitalWrite(CS, LOW);
if(!digitalRead(MISO_RDY)) {
  //chip is ready to send data
  MyData=SPI.transfer(0);
  //process new data...

} else {
  //chip is not ready

}
digitalWrite(CS, HIGH); //finish communications with AD7175

Note this is not using the Due's extended SPI methods as we wish to retain control over the CS pin.
"The problem is in the code you didn't post."

bob4i

I've tried with Arduino Uno and it is OK, but with due can not catch the low level of MISO. May be there is a problem when i declare MISO. I've tried with separate signal but never goes low, or I can not catch, because when I measure the voltage it is 0V. I use due for first time and may be there are some tiny tricks I don't know. Tomorrow I will try again.

dlloyd

#3
Dec 02, 2014, 10:53 pm Last Edit: Dec 02, 2014, 11:01 pm by dlloyd
Is the ADC connected so that all of its I/O is at 3.3V and VDD is 3.3V?
A connection diagram would help.

On the Due, this is where you connect the SPI signals:



Have you checked out this reference page?
http://arduino.cc/en/Reference/DueExtendedSPI

From the datasheet, it mentions that this ADC requires SPI mode 3.

Something like this might get you started (untested):

Code: [Select]
#include <SPI.h>
#define CS 52  // can use pins 4, 10, or 52 for CS

void setup()
{
  SPI.begin(CS);
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(CS, SPI_MODE3);
  SPI.setClockDivider(CS, 6);  // 14MHz (closest available to 16MHz in datasheet)
}

void loop()
{
  byte msg1 = 0x02;
  byte msg2 = 0x00;
  byte msg3 = 0x80;
  byte msg4 = 0x00;

  // begin transfer...
  SPI.transfer(CS, msg1, SPI_CONTINUE);  // CS goes LOW
  SPI.transfer(CS, msg2, SPI_CONTINUE);
  SPI.transfer(CS, msg3, SPI_CONTINUE);
  SPI.transfer(CS, msg4);                // CS goes HIGH
}

bob4i

SPI is wired correct, VDD is 3.3V. When I wrote 8010HEX to mode register I red 801HEX but when I wrote 801F I red 801F. When I am trying to use MISO as a rdy output data a lot of data is mismatched, I suppose       have to try without this signal. I will play more next week because I have other tasks now and I will reply.
Thanks for the help.

Go Up