Part Number:ADS7953
I have referred all the threads regarding the ADS7953 on the TI forums. I have developed a code , i think the programming sequence and code is correct but it is always better to have a second pair of eyes to see whats wrong.
Can you please check the code and confirm whether it is correct or not ? if the code is correct then i can start looking into the design and schematics for issues. I dont have a logic analyzer so its really hard to tell the origin of the issue.
the code is attached below. All i am getting is 0 in response which means the communication is failing.
one more question : can i just write simple commands and expect a response from ADS7953 ? without any configuration ?
i.e : to Read channel 0
while(1)
{
CS_LOW
spi.transfer(0x10);
spi_transfer(0x80);
CS_HIGH
CS_LOW
int data_high = spi_transfer(0x00);
int data_low = spi_transfer(0x00);
CS_HIGH
delay(2000);
}
#include <SPI.h> SPIClass * vspi = NULL; SPIClass * hspi = NULL; auto ADC_CLK = 4000000; #define mosi 14 #define miso 12 #define cs 13 #define clk 27 unsigned int cmd_1 = 0x4200; unsigned int cmd_2 = 0x8000; unsigned int cmd_3 = 0xFFFF; unsigned int cmd_4 = 0x2C00; unsigned int cmd_5 = 0x2840; unsigned int cmd_6 = 0x0000; void setup() { // put your setup code here, to run once: // init_spi(); Serial.begin(115200); pinMode(26, OUTPUT); pinMode(5, OUTPUT); digitalWrite(26, HIGH); digitalWrite(5, HIGH); pinMode(cs, OUTPUT); digitalWrite(cs,HIGH); hspi = new SPIClass(HSPI); hspi->begin(clk, miso, mosi, cs); delay(1000); ads7953_setup(); Serial.println("Setup complete"); } void loop() { ads7953_readData(); delay(1000); } void ads7953_setup() { digitalWrite(cs, HIGH); delay(5); /* Reset Command */ hspi->beginTransaction(SPISettings(ADC_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(cs, LOW); hspi->transfer16(cmd_1); digitalWrite(cs, HIGH); hspi->endTransaction(); delay(100); hspi->beginTransaction(SPISettings(ADC_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(cs, LOW); hspi->transfer16(cmd_2); digitalWrite(cs, HIGH); hspi->endTransaction(); delay(100); hspi->beginTransaction(SPISettings(ADC_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(cs, LOW); hspi->transfer16(cmd_3); digitalWrite(cs, HIGH); hspi->endTransaction(); delay(100); hspi->beginTransaction(SPISettings(ADC_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(cs, LOW); hspi->transfer16(cmd_4); digitalWrite(cs, HIGH); hspi->endTransaction(); delay(100); hspi->beginTransaction(SPISettings(ADC_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(cs, LOW); hspi->transfer16(cmd_5); digitalWrite(cs, HIGH); hspi->endTransaction(); delay(100); hspi->beginTransaction(SPISettings(ADC_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(cs, LOW); hspi->transfer16(cmd_6); digitalWrite(cs, HIGH); hspi->endTransaction(); delay(100); } void ads7953_readData() { hspi->beginTransaction(SPISettings(ADC_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(cs, LOW); int received_data = hspi->transfer16(cmd_6); digitalWrite(cs, HIGH); hspi->endTransaction(); Serial.print("Received Data : "); Serial.println(received_data); delay(10); }