Post Go back to editing

AD7715 doesn't run as expected (no conversion)

Hello,

I'm trying to interface two AD7715 with an ATMega1284 MPU. On this board, I have three SPI devices :

  • one TLC1665 (that runs fine, without any trouble);
  • two AD7715.

I cannot add an image, thus i will try to explain how I have connected this device (powered with a 5V regulated power supply and of course a lot of capacitors).

  • AIN- : GND
  • AIN+ : signal of interest (between 0 and 4V)
  • REFIN- : GND
  • REFIN+ : 5V
  • #CS comes from a 74HCT138N
  • SCLK, DIN, DOUT are connected to MPU with pull-up resistors.
  • #DRDY is connected to MPU (I have tested with this signal or with register with the same bad result).

SPI bus runs fine in 8-bits mode as TLC1665 runs as expected (@ 250 kHz). I have checked that signals are clean on AD7715. Thus, I suppose I have done a mistake anywhere.

To access to SPI bus, I have written some functions :

uint8_t
spi_send8(int8_t device, uint8_t data)
{
spi_set_device(device);
SPDR = data;
while(!(SPSR & (1 << SPIF)));
spi_set_device(spi_none);

return(SPDR);
}

uint16_t
spi_send16(int8_t device, uint16_t data)
{
uint16_t tmp;

spi_set_device(device);

SPDR = data >> 8;
while(!(SPSR & (1 << SPIF)));
tmp = SPDR << 8;

SPDR = data & 0xFF;
while(!(SPSR & (1 << SPIF)));
tmp |= SPDR;

spi_set_device(spi_none);

return(tmp);
}

set_device(dev) is a function that set two lines of MPU to select SPI slave through 74HCT138N. This function runs also as expected. Now, I'm trying to read data from AD7715.

ad7715_rcan_init()
{
spi_send8(spi_rcan, 0x11);
spi_send8(spi_rcan, 0x7C);
while(PINC & (1 << DDC5)); // DRDY
return;
}

uint16_t
ad7715_read_rcan_data()
{
while(PINC & (1 << DDC5));
spi_send8(spi_rcan, 0x39);
return(spi_send16(spi_rcan, 0x0000));
}

First time I call ad7715_read_rcan_data(), I read a value. But always the same and regardless the real value on pin AIN+. And all other read actions return 0. Where is my mistake ?

Best regards,

JB

Parents
  • Some news.

    When I configure this converter in buffered mode, I obtain expected value (but only once) :

    void ad7715_rcan_init()
    {
    spi_send8(spi_rcan, 0x10);
    spi_send8(spi_rcan, 0x6F);
    while(PINC & (1 << DDC5));
    return;
    }

    uint16_t ad7715_read_rcan_data()
    {
    while(PINC & (1 << DDC5));
    spi_send8(spi_rcan, 0x38);
    return(spi_send16(spi_rcan, 0xFFFF));
    }

    First remark : when I try to read a register, values sent over SPI lines are important. They are NOT ignored even if datasheet indicates they are ignored. I have to send 0xFF, not any other value.

    That's being said, I don't understand my mistake.

    I have verified that RDRY goes high and down after self calibration. This line is low and I can read the first value (expected value, thus converter seems to work as expected for the first value).

    Second read attempt enters in a dead lock as RDRY remains high.

    In FAQ, I have found some explanations about serial line corruption but I'm not sure, in my cas, serial line is corrupted. Indeed, if I remove DRDY test, I can continuously set control register and read the same value.

    Best regards,

    JB

  • Hi, 

    I'm not a coder, so I can't help you with any code specific query. But in terms of the behavior, can you clarify if you can successfully write and readback to a certain registers other than the data register? Have you tried reading back the setup register for example just to confirm that your SPI communication is working properly?

    If the above check works fine, and if you only get invalid data from data register then another possible test  is to stop reading conversions and just monitor the DRDY pin with /CS low and see if this is pulsing at correct output data rate. 

    I would also recommend to perform the above test on a single ADC only. It will be easy to debug it on a single ADC and then you can just add the other one when everything works fine on a single ADC. 

    Thanks,

    Jellenie 

Reply
  • Hi, 

    I'm not a coder, so I can't help you with any code specific query. But in terms of the behavior, can you clarify if you can successfully write and readback to a certain registers other than the data register? Have you tried reading back the setup register for example just to confirm that your SPI communication is working properly?

    If the above check works fine, and if you only get invalid data from data register then another possible test  is to stop reading conversions and just monitor the DRDY pin with /CS low and see if this is pulsing at correct output data rate. 

    I would also recommend to perform the above test on a single ADC only. It will be easy to debug it on a single ADC and then you can just add the other one when everything works fine on a single ADC. 

    Thanks,

    Jellenie 

Children
No Data