Hi,
I have ADS1299 EEG-FE evaluation board through which I am trying to read its register values by using SPI communication through Arduino Due Microcontroller. I have used the following code in which at first, I have sent a RESET command and then I have sent Register Read command for CONFIG1 register. According to its datasheet, I should get a value 96h. But I am getting random values at each iteration of the loop. I want to know the sequence of steps needed to read register values and subsequently to read data values from channels.
The code is as follows:
#include<SPI.h>
byte Value = 0xA9; // The variable to store the value of incoming byte. Setting a predefined value so that if there is no data transferred, it shows a predefined value on oscilloscope.
void setup() {
// put your setup code here, to run once:
pinMode(10, OUTPUT); // Chip Select
pinMode(8, OUTPUT); // Output on Oscilloscope
SPI.begin();
SPI.beginTransaction(SPISettings(1500000, MSBFIRST, SPI_MODE1)); // 1.5 MHz
digitalWrite(10, LOW); // Chip Select LOW
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(8, LOW); // Begin oscilloscope by 0
delay(100);
SPI.transfer(0x06); // RESET Command issued
delayMicroseconds(20); // Delay of more than 18 clock cycles
SPI.transfer(0x11); // Stop Data command
delayMicroseconds(20);
SPI.transfer(0x21); // Send Read register command with address of register
delayMicroseconds(3);
SPI.transfer(0x00); // Read only one register
delayMicroseconds(3);
Value = SPI.transfer(0x00); // Read the value
delayMicroseconds(3);
for (int i=0; i<8; i++)
{
digitalWrite(8, bitRead(Value,7-i)); // Display the value on oscilloscope
delay(100);
}
digitalWrite(8, LOW);
delay(1000);
}
Thanks,