Post Go back to editing

Trouble configuring ADGS1409 with Arduino/ESP32

Category: Software
Product Number: ADGS1409

I am trying to use the ADGS1409 with an Arduino Uno and also with an ESP32. I want to initially set the channel to S1 and once I am done with that I will add a loop to cycle through the other channels using the burst mode but for some reason I am unable to set up channel 1. For now I am setting all the other error config bits to zero as I just want to get this to work and will later enable them. I have tried it with the SDP-S board and ACE software to test the functionality of the board and it worked. I am currently using only the single supply mode by providing 12v to VDD and GND to GND and VSS. The EXT_VAL pin is connected to the arduinos 5V output pin and I am supplying 3.3v to S1A and connecting S1B to GND.

I would like your help to figure out where I've gone wrong or where I've made any mistakes and also to know if I have missed anything in this post.

This is the Arduino Code:

#include <SPI.h>

#define SS 10
const byte sw_add = 0b00000001;
const byte sw_ch1 = 0b00000001;
const byte err_add = 0b00000010;
const byte err_val = 0b00000000;

void setup() {
  Serial.begin(115200);
  digitalWrite(SS, HIGH);
  SPI.begin();
  //SPI.setClockDivider(SPI_CLOCK_DIV4);
    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
  digitalWrite(SS, LOW);
  SPI.transfer(err_add);
  SPI.transfer(err_val);
  digitalWrite(SS, HIGH);
  digitalWrite(SS, LOW);
  SPI.transfer(sw_add);
  SPI.transfer(sw_ch1);
  digitalWrite(SS, HIGH);
  SPI.endTransaction();
}

void loop() {
  // put your main code here, to run repeatedly:


}

This is the ESP32 Code:

#include <SPI.h>


#define VSPI_MISO   19
#define VSPI_MOSI   18
#define VSPI_SCLK   5
#define VSPI_SS     21
const uint16_t SW_DataWrite = 0x0101;
const uint16_t SW_DataRead = 0x8100;
const uint16_t ERR_Config = 0x0200;
static const int spiClk = 100000; // 100 kHz

//uninitalised pointers to SPI objects
SPIClass * vspi = NULL;

void setup() {
   //clock miso mosi ss
  Serial.begin(115200);
  Serial.println("SPI config begin");
  vspi->begin(VSPI_SCLK, VSPI_MISO, VSPI_MOSI, VSPI_SS);

  //initialise vspi with default pins
  //SCLK = 18, MISO = 19, MOSI = 23, SS = 5
  //vspi->begin();
  //set up slave select pins as outputs as the Arduino API
  //doesn't handle automatically pulling SS low
  pinMode(VSPI_SS, OUTPUT);
  Serial.println("SPI init done");

  // To configure registers
  Serial.println("Configuring registers ...");
  vspiCommand(ERR_Config);
  vspiCommand(SW_DataWrite);

}

// the loop function runs over and over again until power down or reset
void loop() {
  
  //uint16_t reg_value = vspiCommand(SW_DataRead);
  //Serial.println(reg_value);
  
  //delay(100);
}


uint16_t vspiCommand(uint16_t command) {
  uint16_t read_data;
  vspi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(VSPI_SS, LOW);
  read_data = vspi->transfer16(command);
  digitalWrite(VSPI_SS, HIGH);
  vspi->endTransaction();
  return read_data;  
}



Added the things I need help with.
[edited by: niteshglx at 1:32 PM (GMT -4) on 14 Jun 2022]
Parents
  • Hi Nitesh,

    I support the SDP-S ( so I'm glad that setup works!) but I'm not familiar with the ADGS1409. I might be able to offer some general advice however. I assume you are using the EVAL-ADGS1408-1409 Evaluation Board | Analog Devices ? And for the Arduino or ESP32 you are using the J5 pin headers to connect your SPI signals?

    Check the positions of links LK1 and LK2 - they should both be at "A" or the ADGS1409 will be held in RESET.

    I would try reading some or all of the registers after power up as a debug step. The ERR_CONFIG register should give you 0x06 for example. Do you have access to an oscilloscope or a logic analyser?

  • Yes, I am using the Eval board, and yes I am using the J5 header. The positions of both LK1 and LK2 is at A. I do have access to both an oscilloscope and a logic analyser, I've tried testing the signal through the logic analyser but couldn't really get anything conclusive from it. I shall try reading the ERR_Config and ERR_Flag resistor next to see what's up but so far my experience with reading register values in this mux have led to failures.

    Thanks a lot for replying.

Reply
  • Yes, I am using the Eval board, and yes I am using the J5 header. The positions of both LK1 and LK2 is at A. I do have access to both an oscilloscope and a logic analyser, I've tried testing the signal through the logic analyser but couldn't really get anything conclusive from it. I shall try reading the ERR_Config and ERR_Flag resistor next to see what's up but so far my experience with reading register values in this mux have led to failures.

    Thanks a lot for replying.

Children
  • As you have a working setup (ACE + SDP-S), you could try some instructions from ACE that you can replicate in your Arduino/ESP32 and compare the screen captures of those SPI transfers?

  • Yeah, I did exactly that, I connected the SDP-S to the MUX and to my system, connected the logic analyser pins to the MUX's sdi, sdo, clk, and cs pins. I then sent a command through ace to switch on channel A and observed the signal that was captured in the Logic analyser. I then switched the setup to the arduino based setup replicated that exact signal on the arduino and it worked. Now I need to set up the reading error flags register part to see if that works. There's a lot more things to update but now I know what to do. I am thinking of writing an arduino library for this mux haha. Thanks a lot for your help David!!