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.

ADS1263: DOUT/DRDY stuck at 0

Part Number: ADS1263

Hello,

I am trying to write and read from the ADS1263 SPI using the STM32F437 processor but the data I get on the DOUT/DRDY is always 0.

The SPI setting I use is:

SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge; 
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; 
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;

The SCLK frequency is 6 MHz (48 M / 8).

To read a register I use the following code:

adc_in[0] = ADS1263_RREG_CMD + REGX    // REGX = 0 .. 26
adc_in[1] = 0;
SPI_ADC_ReadReg(adc_in, adc_out);

The function SPI_ADC_ReadReg look like this:

void SPI_ADC_ReadReg(u8 u8 *adc_in, u8 *adc_out)
{

/* Loop while DR register in not emplty */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);

/* Select the ADC: Chip Select low */
SPI_ADC_CS1_LOW;
for (int i=0; i<3+adc_in[1]; i++)
{

/* Send Half Word through the SPI2 peripheral */
SPI_I2S_SendData(SPI1, adc_in[i]);

/* Loop while DR register in not emplty */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
}

/* Wait to receive a byte */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);

/* Loop while DR register in not emplty */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);

/* Return the Half Word read from the SPI bus */
adc_out[0] = SPI_I2S_ReceiveData(SPI1);

/* Deselect the ADC: Chip Select low */
SPI_ADC_CS1_HIGH;
}

 On a logic scope all the signals - CS, SCLK and MOSI look OK. Only DOUT/DRDY is stuck at 0.

Can you tell me what I'm missing?

Thanks

  • Ehud,


    There are a couple of things that you can check if you're having problems with communications. However, it first helps to get a scope shot or logic analyzer read of the SPI communications. Then compare them with the timing diagrams in the datasheet. A look at the SCLK, DIN, DOUT, and /CS may give a quick answer.

    Also, I would check the START and /RESET to make sure that they are high so that the device is working and not in a sleep or reset mode.

    As for the code, I'm not the best person about code questions, but check on the SPI flavor. I think for the STM32F437, it should be set to SPI_CPHA_2Edge instead of SPI_CPHA_1Edge. Check it for yourself, but the data is clocked on the falling edge of SCLK. Also, check to see that the /CS is low for the entire communication. If you are reading or writing from the register, the /CS should be low for the entire SPI transaction, not byte to byte (in your code, I thought it looked ok, but again I'm not much of a programmer).

    After that verify the timing. The SCLK frequency should be 8MHz max.

    Regardless, the scope shot should be the first step. Once you get that, you can post the results here.


    Joseph Wu
  • Hi Joseph,
    Thanks for your advice.
    I changed the SPI setting to SPI_CPHA_2Edge and it helped !!
    Now I see the right value of the register on the DOUT / DRDY line.
    I still have a problem to read it in the 437 - but this is probably another setting problem that I'll try to solve.

    Thanks again.
  • Ehud,


    I'm glad the SPI CPHA change worked. Again, if you need more help with debugging the communications, feel free to post scope shots or logic analyzer outputs.


    Joseph Wu
  • Hi Joseph

    So I finally got the ReadReg function to work.

    The problem was: You have to read the first 2 bytes and discard them. So for anyone who is interested here are the settings and function that work for reading 1 register :

    Setting:

      SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
      SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
      SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
      SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
      SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge; //SPI_CPHA_2Edge
      SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
      SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_8; //If using SPI_BaudRatePrescaler_4, will create garbage data im M25P128
      SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
      SPI_InitStructure.SPI_CRCPolynomial = 7;

    Function:

    void SPI_ADC_ReadReg(u8 *adc_in, u8 *adc_out)
    {
     
      /* Loop while DR register in not emplty */
      while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);

      /* Select the ADC: Chip Select low */
      SPI_ADC_CS1_LOW;
      for (int i=0; i<3]; i++)
      {

       /* Send Half Word through the SPI2 peripheral */
        SPI_I2S_SendData(SPI1, adc_in[i]);

        /* Loop while DR register in not emplty */
        while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);

        /* Wait to receive a byte */
        while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);

        /* Return the Half Word read from the SPI bus */
        adc_out[0] = SPI_I2S_ReceiveData(SPI1);
      }

    }

    Thanks again

  • Hi Ehud,

    That is correct. The first two return bytes (during the RREG + NUM command bytes) are insignificant and should be discarded.

    Let us know if you have any additional questions about the ADS1263!

    Best regards,
    Chris