Go Back   Home > Forums > >
Home Forums Rules Articles diyAudio Store Blogs Gallery Wiki Register Donations FAQ Calendar Search Today's Posts Mark Forums Read

Digital Line Level DACs, Digital Crossovers, Equalizers, etc.

Arduino Control of SRC4392
Arduino Control of SRC4392
Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 6th June 2018, 04:58 PM   #1
GOR3 is offline GOR3  United States
diyAudio Member
 
Join Date: Jun 2011
Location: Connecticut
Default Arduino Control of SRC4392

Does anyone have an Arduino sketch to control the TI SRC4392 sample rate converter chip?
Thanks,
George
  Reply With Quote
Old 7th June 2018, 02:30 PM   #2
Neil Davis is offline Neil Davis  United States
diyAudio Member
 
Join Date: Dec 2004
Location: Reston, Virginia
Arduino Control of SRC4392
Not an actual sketch or library, but working code from a sketch:

Quote:
const uint8_t SRC4382_reg_01 = 0x01; //Power-Down and Reset address
const uint8_t SRC4382_reg_01_data = 0x3B; //SRC on, RX on, Ports A and B on

Wire.beginTransmission(I2C_addr); // transmit to SRC
Wire.write(SRC4382_reg_01);
Wire.write(SRC4382_reg_01_data); //write reg number followed by data
Wire.endTransmission();
And so on...

Lots of registers to initialize, and this code gets repeated for each register.

Reading the registers is more complicated because you have to set the internal address counter with a write before you can issue a read:

Quote:
byte SRC_check(uint8_t SRC_reg_num) {
byte reg_data;
Wire.beginTransmission(SRC4382_addr); // transmit to SRC
Wire.write(SRC_reg_num); //send the register number
Wire.endTransmission(false); //Address counter set

Wire.requestFrom(SRC4382_addr, 1, true);
if ( Wire.available() >= 1 ) reg_data = Wire.read();
return reg_data;
}
  Reply With Quote
Old 7th June 2018, 03:39 PM   #3
GOR3 is offline GOR3  United States
diyAudio Member
 
Join Date: Jun 2011
Location: Connecticut
Thanks, Neil. This is a start. I'm so not a software guy.
George
  Reply With Quote
Old 9th June 2018, 07:06 PM   #4
Markw4 is offline Markw4  United States
diyAudio Member
 
Join Date: Jul 2016
Location: California
I have done this. It's not hard actually. First thing is decide on I2C or SPI since SRC4392 supports both. I2C is probably easier and there are a number of libraries. Care should be exercised not to blow up the SRC I2C pins with inadvertent over-voltage from the Arduino if the two devices are separately powered, likewise probably wise to be sure the Arduino is protected. Level translators are one solution. There are also a few 3.3v Arduinos which could potentially help simplify things.

May I ask if the SRC 4392 is already in a circuit somewhere? And have you already chosen the Arduino you want to use?

Also, I probably have some code I could share with you to configure SRC4392 for conversion of any input to a fixed output sample rate. Can also provide some information about programming it to do other things.

Last edited by Markw4; 9th June 2018 at 07:16 PM.
  Reply With Quote
Old 10th June 2018, 12:55 AM   #5
Neil Davis is offline Neil Davis  United States
diyAudio Member
 
Join Date: Dec 2004
Location: Reston, Virginia
Arduino Control of SRC4392
+1 on the 3.3V warning. I've been using the teensy micros, and I keep forgetting that so many of the Arduino boards still use 5V. The I2C inputs aren't 5V tolerant.

The SRC4392 is one of the few chips that allows sending data along with the audio on the SPDIF stream. There are two "user" bits (left and right) defined in the I2S standard that can be used for messaging. It's a convenient way to send volume and other control information to active speakers. I've got code and a simple message protocol for the SRC4392, but the code is all written in 6801 assembly language (and it has to be interrupt-driven to work properly). The code probably wouldn't be very useful to you, but it's available.
  Reply With Quote
Old 11th June 2018, 02:23 PM   #6
GOR3 is offline GOR3  United States
diyAudio Member
 
Join Date: Jun 2011
Location: Connecticut
Quote:
Originally Posted by Markw4 View Post
May I ask if the SRC 4392 is already in a circuit somewhere? And have you already chosen the Arduino you want to use?
The SRC4392 is not in a circuit yet. I plan to use an Arduino Uno Rev. 3. I know I have to level shift.

Quote:
Originally Posted by Markw4 View Post
Also, I probably have some code I could share with you to configure SRC4392 for conversion of any input to a fixed output sample rate.
Wonderful. That would be a big help. I have read the DS a dozen times and could not figure out how to do this.
Thanks,
George
  Reply With Quote
Old 11th June 2018, 03:16 PM   #7
Markw4 is offline Markw4  United States
diyAudio Member
 
Join Date: Jul 2016
Location: California
Let's see.... Looks like I have a snippet that still has some delays in it left over from some test and debugging, and there is an unnecessary volume level change, but I think it works. The output sample rate in this case is a function of the master clock frequency. Sometimes people will use one clock for 44kHz and its multiples connected as MCLK and another clock for 48kHz and its multiples connected as RXCKI.

One thing maybe to consider is that intersample overs can occur during SRC calculations with any SRC. If it is desired to prevent that possibility, say, if using Windows as a SPDIF source, the sound card Properties settings in the Windows control panel can be used to turn down the master volume level for the device by 3.5dB or so which is enough (I think) for the worst case potential intersample over.

Anyway, you are welcome to take a look and please feel free to ask if you have any questions.
Attached Files
File Type: pdf 96kHz.pdf (59.1 KB, 31 views)

Last edited by Markw4; 11th June 2018 at 03:19 PM.
  Reply With Quote
Old 11th June 2018, 03:25 PM   #8
GOR3 is offline GOR3  United States
diyAudio Member
 
Join Date: Jun 2011
Location: Connecticut
Thanks, Mark. I'll take a look.
George
  Reply With Quote

Reply


Arduino Control of SRC4392Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Arduino Nano based GC control zdr Chip Amps 2 22nd August 2016 07:12 PM
Low cost Arduino based total amp control zdr Analog Line Level 11 16th May 2016 06:25 PM
Using Arduino for Syncronous motor speed control SuperTuck Analogue Source 2 23rd April 2013 10:10 AM
Use Arduino to control BIII bigpandahk Twisted Pear 4 9th August 2012 08:52 AM
Arduino for pre-amp or DAC control Zero Cool Everything Else 2 6th August 2011 01:55 PM


New To Site? Need Help?

All times are GMT. The time now is 04:29 AM.


Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 14.29%
vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2018 DragonByte Technologies Ltd.
Copyright ©1999-2018 diyAudio
Wiki