AnsweredAssumed Answered

AD7124-4 RDY bit always set to 1

Question asked by alessio31183 on Oct 13, 2017
Latest reply on Oct 17, 2017 by JellenieR

Dear all,

I made the Arduino porting communication code for the AD7124 library provided by Analog on github.

Making my sketch where I'm using just one AD7124 I'm not able to read data from the converter even having the right data register setting:

 

This is done in setup function

 

  // Initialize AD7124 device
  ret = AD7124_Setup(ad7124_handler, AD7124_SLAVE_ID, (ad7124_st_reg *)&ad7124_regs);  
 
  if (ret < 0)
    Serial.println(F("AD7124 initialization failed, check the value of ret!"));
  else
    Serial.println(F("AD7124 initialization OK"));
 
  // Enable the channel, Setup #0 for this channel, AIN5 = AINP, AIN4 = AINM
  ad7124_regs[AD7124_Channel_0].value = AD7124_CH_MAP_REG_CH_ENABLE | AD7124_CH_MAP_REG_SETUP(0) | AD7124_CH_MAP_REG_AINP(5) | AD7124_CH_MAP_REG_AINM(4);                                 
  ad7124_regs[AD7124_Channel_0].value &= 0xFFFF;
  AD7124_WriteRegister(ad7124_handler, ad7124_regs[AD7124_Channel_0]);
 
  ad7124_regs[AD7124_Config_0].value = AD7124_CFG_REG_REF_BUFP | AD7124_CFG_REG_REF_BUFM | AD7124_CFG_REG_AIN_BUFP | AD7124_CFG_REG_AINN_BUFM | AD7124_CFG_REG_PGA(ADC_GAIN);     
  ad7124_regs[AD7124_Config_0].value &= 0xFFFF;
  AD7124_WriteRegister(ad7124_handler, ad7124_regs[AD7124_Config_0]);

 

  ad7124_regs[AD7124_Filter_0].value= AD7124_FILT_REG_SINGLE_CYCLE | AD7124_FILT_REG_FS(2047);
  ad7124_regs[AD7124_Filter_0].value &= 0xFFFFFF;
  AD7124_WriteRegister(ad7124_handler, ad7124_regs[AD7124_Filter_0]);
 
  // Continuos read, Full power, Continuous conversion mode, internal 614.4 kHz clock
  ad7124_regs[AD7124_ADC_Control].value = AD7124_ADC_CTRL_REG_CONT_READ | AD7124_ADC_CTRL_REG_CS_EN | AD7124_ADC_CTRL_REG_POWER_MODE(3) | AD7124_ADC_CTRL_REG_MODE(0) | AD7124_ADC_CTRL_REG_CLK_SEL(0);               
  ad7124_regs[AD7124_ADC_Control].value &= 0xFFFF;
  AD7124_WriteRegister(ad7124_handler, ad7124_regs[AD7124_ADC_Control]);

 

 

This is in loop function:

 

    // Read data from the ADC
    
    ret = AD7124_WaitForConvReady(ad7124_handler, timeout);
    if (ret < 0)
      Serial.println(F("Something went wrong, check the value of ret!"));    // FOR DEBUG ONLY
    
    ret = AD7124_ReadData(ad7124_handler, sample);
    if (ret < 0)
      Serial.println(F("Something went wrong, check the value of ret!"));    // FOR DEBUG ONLY

 

Here if I try to read the status reg I have the RDY always "1".

 

I cannot figure out why because if I read the register value, they are well set.

 

Any suggestion?

Attachments

Outcomes