Arduino Control of SRC4392

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Member
Joined 2004
Paid Member
Not an actual sketch or library, but working code from a sketch:

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:

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;
}
 
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:
Member
Joined 2004
Paid Member
+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.
 
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.

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
 
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.
 

Attachments

  • 96kHz.pdf
    59.1 KB · Views: 217
Last edited:
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.