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.

ADS1298: ADS1298 Reading register

Part Number: ADS1298

Hi,

I am reading and writing from and to a register of ADS1298 AFE through SPI communication. My Master is STM32F411CEU6. I am able to write to a register but not able to read from a register.

The register I am reading from is the ID Control Register (address: 00h). So the opcodes I am sending is 

uint8_t opcode1 = 0x20; // For address

uint8_t opcode2 = 0x00; // register-1

Before sending the opcode I am making it as SDATAC. But still I am not reading the correct value (supposed to be 0x02 since I am using 1298). I am getting the value as 0x49.

Given Below is the complete code

while (1)

{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

uint8_t sdatac = 0x11; // Data to be transmitted

uint8_t opcode1 = 0x20; // Data to be transmitted

uint8_t opcode2 = 0x00; // Data to be transmitted

uint8_t rxData;

// SDATAC Configuration

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); // CS low

HAL_Delay(10);

HAL_SPI_Transmit(&hspi1, &sdatac, 1, HAL_MAX_DELAY); // Transmit data

HAL_Delay(10);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // CS high

HAL_Delay(100);

/////////SDATAC Configuration completes//////////////

// Reading from 00H register

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET); // CS low

HAL_Delay(10);

HAL_SPI_Transmit(&hspi1, &opcode1, 1, HAL_MAX_DELAY); // Transmit data

HAL_Delay(4);

HAL_SPI_Transmit(&hspi1, &opcode2, 1, HAL_MAX_DELAY); // Transmit data

HAL_Delay(100);

HAL_SPI_Receive(&hspi1, &rxData, 1, HAL_MAX_DELAY); // Receive data

HAL_Delay(10);

HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // CS high

if(rxData == 0x02)

{

HAL_GPIO_WritePin(GPIOB, GPIO_PIN_4, GPIO_PIN_SET); // CS low

}

//////Ends here///////////

HAL_Delay(1000);

}