This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADS124S08: Device Ready Flag (!RDY) high after RESET command

Part Number: ADS124S08

Tool/software:

Hi,
I'm following the pseudo-code example from the datasheet (10.1.6, pg. 90)
datasheet pseudocode

but when I send the RESET command and then read the status register (using the RREG command) to check the device ready flag it always comes back as 1.

Before sending the RESET command it was 0 (as it should be). I've tried with bigger delays and/or different SPI speeds but it is always the same result.
I've also tried other libraries and the result is the same.

I don't know if I'm misunderstanding something or if I'm doing something wrong.

Here is the code

library:

// C++
#include "PUADS124S08.h"

void PUADS124S08::deselect()
{
  digitalWrite(cs, HIGH);
  SPI.endTransaction();
  // Wait >~20ns
  asm (
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
  );
}

void PUADS124S08::select()
{
  SPI.beginTransaction(spisett);
  digitalWrite(cs, LOW);
  // TODO: Wait 4096 * (1 / freq)
  asm (
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
    "nop" "\n"
  );
}

PUADS124S08::PUADS124S08(int cs) : cs(cs)
{
  pinMode(cs, OUTPUT);
  deselect();
}

bool PUADS124S08::reset()
{
  select();
  SPI.transfer(Commands::RESET);
  deselect();

  delayMicroseconds(100);
  if (!isready())
  {
    return false;
  }
  // TODO: FL_POR flag
  return true;
}

bool PUADS124S08::isready()
{
  uint8_t byte = readb(Registers::STATUS);

  #ifdef DEBUG
  Serial.println(millis());
  Serial.print("Status register: ");
  Serial.print("0b");
  Serial.print(byte, BIN);
  Serial.println();
  #endif

  return !(byte & 0b01000000);
}

uint8_t PUADS124S08::readb(uint8_t adrr)
{
  uint8_t com = Commands::RREG | (adrr & 0b00011111);
  uint8_t r;
  select();
  SPI.transfer(com);
  SPI.transfer(0x00);
  r = SPI.transfer(0x00);
  deselect();
  return r;
}

main:

(codeblock not working)

```cpp
// main.cpp
#include <Arduino.h>
#include <PUADS124S08.h>

#define MISO 16
#define MOSI 19

PUADS124S08 adc1;

void setup() {
  delay(3000);
  pinMode(MISO, INPUT);
  pinMode(MOSI, OUTPUT);

  Serial.begin(115200);
  SPI.begin();
 
  adc1 = PUADS124S08(15);
  Serial.println(adc1.isready());

  // adc1.reset();
  while (!adc1.reset())
  {
    Serial.println("Error");
    delay(1000);
  }
  Serial.println("ADC Init");
  while(1);
}
```

// main.cpp
#include <Arduino.h>
#include <PUADS124S08.h>

#define MISO 16
#define MOSI 19

PUADS124S08 adc1;

void setup() {
  delay(3000);
  pinMode(MISO, INPUT);
  pinMode(MOSI, OUTPUT);

  Serial.begin(115200);
  SPI.begin();
  
  adc1 = PUADS124S08(15);
  Serial.println(adc1.isready());

  // adc1.reset();
  while (!adc1.reset())
  {
    Serial.println("Error");
    delay(1000);
  }
  Serial.println("ADC Init");
  while(1);
}

serial:

740063
Status register: 0b11000000
Error
...
740231
Status register: 0b11000000
Error

Logic Analyzer

RESET:

RREG:

then I send 0x00

and 0x00 again to read the MISO:

Electric diagram:

Also I'm using a raspberry pi pico (rp2040) with the Arduino framework

Any help would be greatly appreciated

Thanks

  • Hi Santiago Gonzalez T,

    Are you toggling CS before and after the RREG command? If not can you try bringing CS high, then low, then send the complete command, then pull CS high again?

    Can you also try pulling the START pin high and seeing if the DRDY pin toggles at ~50 Hz?  This will help us figure out if the ADC is working. You could also try sending the START command, assuming the device is correctly interpreting your commands

    -Bryan

  • Hi, yes CS is toggled. It is high when no operation is needed and goes low and waits ~20ns (if my calculations are correct) before any transfer, then after the transfer it goes high and waits again, I'll double check just in case.

    I'm using the ADC with commands only, I could try using the START and DRDY pins but I'd rather use commands only.

    I assume commands are correctly interpreted or at least the RREG command because when reading all registers at startup I get the default values from the datasheet.

    If I ignore the pseudo-code example from the datasheet and just write my config to the registers at power-up and send the START command it apparently does start the conversions and I can get data (I guess) with the RDATA command.

  • Hi Santiago Gonzalez T,

    m using the ADC with commands only, I could try using the START and DRDY pins but I'd rather use commands only.

    This is just a troubleshooting step that I am recommending to make sure the ADC is working properly. It is not a suggestion to change your scheme permanently, the device should work well using pins or commands

    If I ignore the pseudo-code example from the datasheet and just write my config to the registers at power-up and send the START command it apparently does start the conversions and I can get data (I guess) with the RDATA command.

    What do you do instead of following the pseudo code? I assume your steps must be similar, so there is something you are not doing that is causing the ADC to perform as expected. I'd like to see if we can narrow down what that is

    -Bryan

  • What do you do instead of following the pseudo code? I assume your steps must be similar, so there is something you are not doing that is causing the ADC to perform as expected. I'd like to see if we can narrow down what that is

    Just write the config to the registers (use internal reference, disable reference buffers, set negative input to AINCOM) and send the START command. Basically skip the part about sending the RESET command and reading the status register.

    Can you also try pulling the START pin high and seeing if the DRDY pin toggles at ~50 Hz? 

    Should I try this after sending the RESTART command? Is it still needed if I can get some data back when sending the START command without sending the RESET command before?

  • Hi Santiago Gonzalez T,

    If you've already got the system working, you don't need to try the START pin or DRDY suggestion I had - that was purely for troubleshooting purposes, and it seems like you've got the ADC working now

    You do not need to poll the RDY bit necessarily, you can just wait the 2.2ms defined in section 9.4.1.1. after power up.

    Let me know if there is anything else

    -Bryan