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.

ADS1262: Reading REG failure

Part Number: ADS1262


I have a problem when I try to read my ADS1262 register.
After preparing an array with reg values (wreg[20]), (where wreg[0] holds wreg[1] , wreg[1]->reg2 etc...)

...
#define ADS126x_NUM_REG 0x15

  uint8_t wreg[20];
   ...
  uint8_t reg_instruction_value=0x41;//WRITE to reg position 1 (reg 0 is ID)
				  
     ADS126xSetCS(0); //set CS Pin LOW

     while(hspi2.State == HAL_SPI_STATE_BUSY);
	HAL_SPI_Transmit(&hspi2,&reg_instruction_value, 1, 0xffff); 
	uint8_t reg_blocks=ADS126x_NUM_REG-0x02; //21reg -1, then -1 for ID
     while(hspi2.State == HAL_SPI_STATE_BUSY);
	HAL_SPI_Transmit ( &hspi2,&reg_blocks, 1, 0xffff);
	 for(int i=0;i<20;i++) //write all 20 registers, from 1 to 21
	    {
		while(hspi2.State == HAL_SPI_STATE_BUSY);
		  HAL_SPI_Transmit (&hspi2, &wreg[i], 1, 0xffff);
	    }
	ADS126xSetCS(1); //to finish writing
	ADS126xSetCS(0);
	
//Reading all registers//
 reg_instruction_value=0x20;//Read
   while(hspi2.State == HAL_SPI_STATE_BUSY);
	HAL_SPI_Transmit ( &hspi2,&reg_instruction_value, 1, 0xffff);
	reg_blocks=ADS126x_NUM_REG-0x01;
   while(hspi2.State == HAL_SPI_STATE_BUSY);
	HAL_SPI_Transmit ( &hspi2,&reg_blocks, 1, 0xffff);
	 for(int i=0;i<21;i++)
	    {
	    while(hspi2.State == HAL_SPI_STATE_BUSY);
	      HAL_SPI_Receive(&hspi2, &AdcRegData[i], 1, 0xffff);
	    }
		ADS126xSetCS(1);
		HAL_Delay(1);
		ADS126xSetCS(0);

This is a screenshot of my signal:



In detail, we can see the write command (0x41 from MOSI) and some regvalus, in particular:
POWER1 : 0x11
Interface: 0x05
Mode0: 0x10
Mode1: 0x80
Mode2: 0x5c ...

Well, after CS HIGH, I start reading but values are wrong:

In detail:

Sometimes values are "better", other times are completly wrong.

MY SPI interface is:

static void MX_SPI2_Init(void)
{

/* USER CODE BEGIN SPI2_Init 0 */

/* USER CODE END SPI2_Init 0 */

/* USER CODE BEGIN SPI2_Init 1 */

/* USER CODE END SPI2_Init 1 */
/* SPI2 parameter configuration*/
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_MASTER;
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 10;
if (HAL_SPI_Init(&hspi2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN SPI2_Init 2 */

/* USER CODE END SPI2_Init 2 */

}

What seems me strange is DRDY, that is HIGH all time long , but how  can I put it LOW? Isn't it an output?

Thanks and best regarts,

Mario

  • Hi Mario,

    I will look into the detail and get it back to you, thanks.

    Regards,

    Dale

  • Hi Mario,

    Your polarity and phase configurations for SPI interface are correct, also I do not see an obvious error in your program and timing. To address the issue, can you please do the experiments below step by step?

    1. Disable register writing subroutine, just read default value of few registers after power up the device, for example, only read one or two internal registers, then check if the retrieved data is correct.
    2. If the data of registers on MISO is correct, then expand to read all 21 registers you want.
    3. If the retrieved data for all registers are correct, write few registers, then read them back to check.
    4. Expand to write and read all registers(write 20 registers and read 21 registers as you want in your program), then check if all retrieved data are correct.

    I'm looking forward to seeing your experiment result.

    Regarding your last question, the /DRDY is an output signal which is data ready indicator(active low). Since you are not doing conversion by either the START or by serial commands, so the /DRDY signal will be always in high state. You can leave this /DRDY pin unconnected if it is unused.

    Regards,

    Dale