Audio DAC (AD1934) control with arduino & raspberry pi : no sound - Page 1
Forum section: electronics / beginners

author: ratatax
author_rank: Regular Contributor
timestamp: July 16, 2019, 06:54:54 pm
content: Hi guys,I have a Raspberry Pi that works well with a Texas Instruments PCM5102A DAC, using I2S communication to output stereo audio 24bit @ 48Khz.I recently switched to an Analog Devices AD1934 chip to experiment with more channels. I'm just trying to make it work but it seems i can't....It's more complicated since in addition to the I2S wires it needs to be configured via SPI for any configuration that isn't the default mode (default expects an external master clock, and I don't have one so I need to use its internal PLL which can create the master clock from the I2S LRCLK clock, like on the PCM5102 dac). So I programmed an Arduino to write the correct registers according to the datasheet :https://www.analog.com/media/en/technical-documentation/data-sheets/AD1934.pdf(control registers page 20)Unfortunately I get no sound, no matter which settings I use.I'm a bit noob in electronics (i'm a software developer) so i'll ask a few questions about what I'm unsure :The datasheet tells the SPI communication works this way :Does it correspond to SPI Mode 0/1/2 or 3 ? Even by reading this well made page :https://www.analog.com/en/analog-dialogue/articles/introduction-to-spi-interface.htmlI'm not sure which mode to use !How I connected the chip :The code I wrote for the Arduino, it just write some registers in a loop :Code:#include <SPI.h>void setup() {SPI.begin ();}// 1Mhz SPI (AD1934 is ok up to 10Mhz)SPISettings settingsA(1000000, MSBFIRST, SPI_MODE2);#define AD1934_PLL_CLK_CTRL0 0x00#define AD1934_PLL_CLK_CTRL1 0x01#define AD1934_DAC_CTRL0 0x02#define AD1934_DAC_CTRL1 0x03#define AD1934_DAC_CTRL2 0x04#define AD1934_DAC_CHNL_MUTE 0x05#define AD1934_DAC_L1_VOL 0x06#define AD1934_DAC_R1_VOL 0x07#define AD1934_DAC_L2_VOL 0x08#define AD1934_DAC_R2_VOL 0x09#define AD1934_DAC_L3_VOL 0x0a#define AD1934_DAC_R3_VOL 0x0b#define AD1934_DAC_L4_VOL 0x0c#define AD1934_DAC_R4_VOL 0x0d#define AD1934_ADC_CTRL0 0x0f#define AD1934_ADC_CTRL1 0x10#define AD1934_GLOBAL_ADDRESS_READ 0x09#define AD1934_GLOBAL_ADDRESS_WRITE 0x08void ad1934_write_reg(unsigned char address, unsigned char data){unsigned char buffer;buffer=AD1934_GLOBAL_ADDRESS_WRITE;buffer=address;buffer=data;SPI.beginTransaction(settingsA);digitalWrite(SS, LOW);SPI.transfer (buffer,3);digitalWrite(SS, HIGH);SPI.endTransaction();delayMicroseconds(50);}void loop() {/* unmute all dac channels */ad1934_write_reg(AD1934_DAC_CHNL_MUTE, 0x0);// see bits in the picture belowad1934_write_reg(AD1934_PLL_CLK_CTRL0, 0b10111100);ad1934_write_reg(AD1934_PLL_CLK_CTRL1, 0);ad1934_write_reg(AD1934_DAC_CTRL0, 0b00000000);ad1934_write_reg(AD1934_DAC_CTRL1, 0b00000000);ad1934_write_reg(AD1934_DAC_CTRL2, 0x1A );delay (100);}Unfortunately, I'm not even sure if I choose the right settings, I find the datasheet confusing :I don't have a scope to check the signals, I'll buy one very soon. If you know the thing about the SPI mode it would already helps me greatly

author: sintechs
author_rank: Newbie
timestamp: May 11, 2022, 09:19:52 am
content: For those who found this topic in a search for an answer why AS1934 does not respond to SPI commands.Try to pull-up CLATCH line to VCC.AD1934 checks this line at reset and if it is LOW, standalone mode is activated which leads to deactivation of SPI control port.