Hi I am using Arduino Nano V3 with ADG739 matrix switch. I am trying to send the data to ADG739 via SPI from Nano. But when I see in the logic analyzer I see no data being sent and obviously the I am not getting any output from ADG739. I have posted my code below.
#include <SPI.h>
const int slaveSelectPin = 10;
const int SCLK = 13;
const byte data1 = 0b00010001;
const byte data2 = 0b01000100;
const byte data3 = 0b00100010;
const byte data4 = 0b00010001;
byte receivedData;
void setup()
{
Serial.begin(9600);
if (DEBUG)
{
while(!Serial);
}
delay (100);
Serial.println("Start");
pinMode(slaveSelectPin, OUTPUT);
pinMode(SCLK, OUTPUT);
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE1);
}
void loop()
{
digitalWrite(slaveSelectPin, LOW);
delay(500);
SPI.transfer(B00010001); //Sending data
receivedData = SPI.transfer(0x00);
delay(500);
digitalWrite(slaveSelectPin, HIGH);
Serial.print("Received data: ");
Serial.println(receivedData);
}
not sure what ur expecting here, the datasheet I found online does not show and MISO connection to the ADG739
how are you checking this? did you confirm all your connections?
maybe something like this might work...
(compiles, NOT tested!)
#include <SPI.h>
const int SS_Pin = 10;
const byte data1 = 0b00010001;
const byte data2 = 0b01000100;
const byte data3 = 0b00100010;
const byte data4 = 0b00010001;
byte receivedData;
void setup ()
{
Serial.begin (9600);
pinMode(SS_Pin, OUTPUT);
digitalWrite(SS_Pin, HIGH); // ensure SS stays high for now
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
Serial.println ("READY");
}
void loop (void)
{
digitalWrite(SS_Pin, LOW);
delay(500);
SPI.transfer(data1); //Sending data
delay(10000);
SPI.transfer(data2); //Sending data
delay(10000);
SPI.transfer(data3); //Sending data
delay(10000);
SPI.transfer(data4); //Sending data
delay(10000);
digitalWrite(SS_Pin, HIGH);
delay(10000);
}
hope that helps...
Hi thank you for your response.
- In the datasheet of ADG739 it says Dout can be connected to MISO of the microcontroller, to see what was the previous input of DIN. So that is what I did there. I expect when the clock signal is rising DOUT to be set to DIN and I receive it in the receiveData byte. - Datasheet says "Data from the previous write cycle is available on the DOUT pin. If the user wishes to verify the data previously written to the input shift register, the DOUT line could be connected to MISO of the MC68HC11, and with SYNC low, the input shift register would clock data out on the rising edges of SCLK. "
- The connections I have confirmed, infact I even got the response before but all of a sudden it stopped I am not sure why. I am checking the output of ADG739 by connecting S1A and S1B switches to an electrode( input) and Da and Db pins(output) to a sensor.
Also in ur reply code u have changed SPI mode to 1, but isn't it mode 0? If CPOL = 0 and CPHA = 1? Or Have I understood it wrong?
Also an update: I used the same code and setup with UNO, that also doesn't work. My multiplexer is fine because I checked with multimeter and all the points are properly soldered. I have two of them and the code doesn't work with both and nothing is shown on logic analyzer. Is there something wrong with my code?
What multiplexer? Did you use a multiplexer in that setup?
If you mean the matrix switch by the term "multiplexer", you cannot check that with a multimeter.
If a logic analyzer doesn't show anything, you're wiring is bad or you have fried the MCU.
Yes, you immediately overwrite the setting with your read call.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.