Hello,
I'm very new to this but I'm trying to program a ADS1198 chip using an Arduino DUE.
I've made a pcb layout following datasheet's page 63 instructions for a unipolar supply.
I can control/read CLKSEL, DRDY, CS, START, RESET and PWDN pins using Arduino's digital pins 8-13.
I've connected Din(MOSI), Dout(MISO) and SCLK to Arduino's ICSP.
I try to communicate with the chip but checking through Arduino's serial (serial.print) I don't get what I expect.
I'm just trying to read some registers so I can ensure proper communication.
Below I have the code for my Arduino DUE
#include "SPI.h" // necessary library
int ss=11; // using digital pin 11 for SPI slave select
int clksel=13;//CLKSEL->1 for internal clock
int pwrdn=8;//active low
int reset=9;//active low
int start=10;
int drdy=12;
void setup() {
Serial.begin(9600);
Serial.setTimeout(2000);
pinMode(ss, OUTPUT); // we use this for SS pin
pinMode(pwrdn, OUTPUT);
pinMode(reset, OUTPUT);
pinMode(start, OUTPUT);
pinMode(drdy, INPUT);
pinMode(clksel, OUTPUT);
SPI.setBitOrder(MSBFIRST);
delay(200);
digitalWrite(clksel, HIGH);
digitalWrite(pwrdn, LOW);
digitalWrite(reset, LOW);
delay(1000);
digitalWrite(pwrdn, HIGH);
digitalWrite(reset, HIGH);
digitalWrite(ss,HIGH);
}
void loop() {
delay(1000); //wait 1s for Power-On Reset
SPI.begin(); // wake up the SPI bus.
SPI.beginTransaction(SPISettings(2000000,MSBFIRST, SPI_MODE1));
digitalWrite(ss,LOW);
delay(200); //wait for 18*t_clk
Serial.print("WAKEUP: ");
Serial.println(SPI.transfer(0x02));
delay(200);
Serial.print("SDATAC: ");
Serial.println(SPI.transfer(0x11));
delay(200);
while(1) {
SPI.transfer(0b00100000);//read ID register
delay(200);
SPI.transfer(0);
delay(200);1
Serial.print("RREG ID: ");
Serial.println(SPI.transfer(0));
delay(2000);
}
}
You don't seem to be putting the CS pin high after each command. With SPI you need to put CS low, send the command, then put CS high. Pin 11 on the Arduino needs to be MOSI (not slave select) and pin 12 MISO. Pins 11 to 13 are the same pins as on the ICSP connection, so you can't use the ICSP differently than pins 11 to 13.
Don't forget I'm using an Arduino DUE.
According to arduino.cc SPI reference Arduino DUE only uses the ICSP pins for SPI only and doesn't mention any particular pin for SS slave.
So it shouldn't matter if I use pins 8 to 13.
Additionally I only have one chip I want to program so I'm not sure if I have to put the CS high after each command but I will give it a try and let you know if anything changes.
I've never worked with DUE and pins are different from the UNO.
That's quite the chip. Are you a Biomed Eng? According to the datasheet, you need CPOL=0 and CPHA=1, or MODE1. So that's right. I know with the UNO, the frequency specified is the max frequency that the UNO will try. The SPI protocol does ask that the slave select or chip select pin goes from low, command, then high. If you tried this and it did not work then maybe recheck your circuit. You can also try SPI with a smaller chip to see if your connections are OK.
Hi,
I am a Biomed Engineer. I did try changing CS's value before and after every command but no luck.
I've checked the board many times.
I've also opened a thread at TI's forum and I'm hoping to get some help.
It is a brainfuck for me because I don't know where to look at.
The board, the chip, arduino, software or hardware.