Hey
I am trying to use ADS124s08 to read the voltage of a battery
AVDD = 5V
DVDD = 3.3V
I am trying to check the SPI communication from microcontroller to the ADC
Am writing 04h register with the data 18h using WREG command and trying to read it back using RREG command. But when I use the RREG command and transfer NOPs to get the register value, nothing is reflected on the MISO line. Instead, even the NOP (00h) is getting reflected on MOSI line
Could you please help me resolving this?
I have attached the code as well as the logic analyzer file
#include <SPI.h>
int cs = 10;
int miso = 12;
int mosi = 11;
int sclk = 13;
uint8_t dummy;
int i;
uint8_t ulDataTx[3];
uint8_t ulDataRx[3];
SPISettings mySPISettings(4000000, MSBFIRST, SPI_MODE1);
void setup() {
// put your setup code here, to run once:
pinMode(sclk, OUTPUT);
pinMode(mosi, OUTPUT);
pinMode(miso, INPUT);
pinMode(cs, OUTPUT);
SPI.begin();
SPI.beginTransaction(mySPISettings);
digitalWrite(cs, LOW);
delay(10);
SPI.transfer(0x06); // Reset command
delay(10);
digitalWrite(cs, HIGH);
SPI.endTransaction();
Serial.begin(9600);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(cs, LOW);
delay(10);
SPI.begin();
SPI.beginTransaction(mySPISettings);
//delay(10);
//SPI.transfer(0x06);
//delay(10);
//SPI.endTransaction();
//SPI.beginTransaction(mySPISettings);
delay(10);
//SPI.transfer(0xAA);
//delay(10);
//SPI.transfer(0x55);
//delay(10);
//dummy = SPI.transfer(0x00);
uint8_t ulDataTx[3];
ulDataTx[0] = 0x40 + (0x04 & 0x1f); //WREG command for 04h
ulDataTx[1] = 0x00;
ulDataTx[2] = 0x18;
//selectDeviceCSLow();
SPI.transfer(ulDataTx[0]);
delayMicroseconds(100);
SPI.transfer(ulDataTx[1]);
delayMicroseconds(100);
SPI.transfer(ulDataTx[2]);
//releaseChipSelect();
delay(10);
//SPI.endTransaction();
//digitalWrite(cs, HIGH);
//delay(10);
byte temp2;
byte temp1;
byte temp0;
Serial.println(temp2);
Serial.println(temp1);
Serial.println(temp0);
//SPI.beginTransaction(mySPISettings);
// take the CS low to select the device:
//digitalWrite(cs, LOW);
delay(10);
// send the device the READ comand to start reading:
SPI.transfer(0x24); //RREG command for 04h
SPI.transfer(0x00);
temp1 = SPI.transfer(0x00);
Serial.println(temp1, HEX);
//temp0 = SPI.transfer(0x00);
delay(10);
digitalWrite(cs, HIGH);
delay(10);
SPI.endTransaction();
}