Interfacing AD1866 with ESP32 using SPI - Problem with 2nd DAC in package (Right)

Thread Starter

skullkid2802

Joined Feb 1, 2019
9
Hi there, I like to use microcontrollers for musical projects and my latest endeavor has been using the ESP32 in tandem with an AD1866 16-bit dual DAC.
The program to communicate with the chip uses SPI, as it was the fastest and most similar to the expected control signals. I have the MOSI signal representing the DR and DL signals, as the datasheet implies they can be tied together, and the CS signal represents the LL signal, while every other 16 bit transfer toggles pin 33 to represent the LR signal.

The left channel output of the DAC outputs the correct test signal (a downward ramp), while the right output stays at around 4.5vDC, when it is programmed to output an upwards sawtooth. Upon swapping the latch signals, the left channel outputs the upwards sawtooth , while the right output remains at 4.5vDC. Attached is the source code and annotated scope traces of the control signal. The chip is outfitted with decoupling capacitors, as well as the noise reduction capacitors, and the outputs are buffered as specified in the datasheet. As a side note,, the ESP32 was programmed using the Arduino IDE. I have reseated the IC and rewired the circuit multiple times to check for shorts but still no luck. Let me know if you have experience in working with this DAC or SPI and if I were to miss a quirk. I appreciate the collective community of knowledgeable individuals that has been built with this site and I hope to hear back soon.

Code:
#include <SPI.h>
#define LR 33
#define VSPI_MISO   MISO
#define VSPI_MOSI   MOSI
#define VSPI_SCLK   SCK
#define VSPI_SS     SS

static const int spiClk = 1000000;
SPIClass * vspi = NULL;

void setup() {
  //initialise two instances of the SPIClass attached to VSPI and HSPI respectively
  vspi = new SPIClass(VSPI);

  //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->pinSS(), OUTPUT); //VSPI SS
  pinMode(LR, OUTPUT); //LATCH RIGHT

}
int16_t left;
int16_t right;


void loop() {
  //use the SPI buses
  spiCommand(vspi, left,right); 
 
  left+=100; //upwards saw
   right=left*-1; //downwards saw
delay(100); //DELAY for scope readability
}

void spiCommand(SPIClass *spi, int16_t data,int16_t dataR) {
  //use it as you would the regular arduino SPI API
  spi->beginTransaction(SPISettings(spiClk, MSBFIRST, SPI_MODE0));
  digitalWrite(spi->pinSS(), HIGH); 
  
  spi->transfer(data>>8);
  spi->transfer(data);
  digitalWrite(spi->pinSS(), LOW);
   digitalWrite(LR, HIGH); 
  spi->transfer(dataR>>8);
  spi->transfer(dataR);
  digitalWrite(LR, LOW);
  spi->endTransaction();
}
IMAGESS.jpg20221021_211456.jpg
 

Thread Starter

skullkid2802

Joined Feb 1, 2019
9
Thanks, but still, I'm not sure I understand. Are the 8 clock cycles in-between the last write and new data required as shown? Also I noticed the LRCKO switches state at exactly half the time of the sample transfer.

Capture.PNG



Also as another troubleshooting experiment, I connected both the latch and data signals together, but it still only outputs on the left channel, when I'd assume it would simply output the same signal on both channels. I am just so puzzled as to why the left channel outputs the correct signal for both channels when swapping the latch lines? The examples in the datasheet all have a shared latch line and 2 data lines, while as far as I can tell, the application requires a single data line if I want to remain using one SPI channel on the ESP32, which further confuses me. Anyways, I will keep experimenting hopefully getting closer to a solution.
 

Thread Starter

skullkid2802

Joined Feb 1, 2019
9
Solution found: Solder bridge on the SOIC16 to DIP adapter :p

I only checked for shorts while the chip was off the breadboard, lo and behold, (multiple) shorts were found, which surprises me considering the left channel's pins were "perfect". Goes to show, you must triple check everything, as the solution may truly be more simple than expected. Thanks again for the support!
 

bidrohini

Joined Jul 29, 2022
190
Solution found: Solder bridge on the SOIC16 to DIP adapter :p

I only checked for shorts while the chip was off the breadboard, lo and behold, (multiple) shorts were found, which surprises me considering the left channel's pins were "perfect". Goes to show, you must triple check everything, as the solution may truly be more simple than expected. Thanks again for the support!
Thanks for the update. Hopefully, it will help many in the future.
 
Top