Post Go back to editing

Trouble configuring ADGS1409 with Arduino/ESP32

Thread Summary

The user is unable to set up channel S1 on the ADGS1409 using an Arduino Uno and ESP32. The final solution involves comparing SPI commands from the ACE software with the Arduino/ESP32 setup to ensure correct register configuration. Key checks include verifying LK1 and LK2 positions at 'A' and confirming VSS is tied to GND. The user plans to read the ERR_CONFIG and ERR_FLAG registers to diagnose issues and is considering writing an Arduino library for the ADGS1409.
AI Generated Content
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;  
}

Edit Notes

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