Write safeload to control Medium Size EQ
Hi all. Good day.
I'm trying to use MCU to send to safeload register to enable/disable Medium size EQ in SS Project. I'm having trouble in doing this.
The drawing was as per attached. I have no idea what's went wrongs. Hoping to get help in this forum.
The testing below were done to control EQ which center frequency is 2000Hz, Q=3, System Frequency Fs=48000Hz
I'm using ADAU 1701-Eval.
Method 1: Mathematics calculation
I had tried to use the mathematics calculation as in Help> Algorithm Information > EQ Algorithm > Peaking
Common Variables:
boost = -40, Fs= 48kHz, f0 = 2000Hz, gain =0,
A = 10^(boost/40)
ω0 = 2*pi*f0/Fs
alpha = sin(ω0)/(2*Q) //(type: Peaking)
gainLinear = 10^(gain/20)
Coefficients
a0 = 1 + alpha/A
a1 = -2 * cos(ω0)
a2 = 1 - alpha/A
b0 = (1 + alpha*A) * gainLinear
b1 = -(2 * cos(ω0)) * gainLinear
b2 = (1 - alpha*A) * gainLinear
Yet, no luck. Because this calculation would gave different values as in Capture Window.
Method 2: Capture Window
I had tried to use data from capture windows(as in attachment below). But still no luck. The 2kHz audio was still heard and persist.
**************************************************************************************************************************************
MCU Safeload Codings:
For you information, I'm using Arduino Ethernet. Communication to DSP was done in I2C. Tested connection is working fine by reading from DSP Readback block.
Here are the main part:
void loop (){
if(clicked){
val_EQ0B1[0] = 0x00; val_EQ0B1[1]= 0x59; val_EQ0B1[2]=0xcf; val_EQ0B1[3] =0x95; // B0 {0x00, 0x59, 0xCF, 0x95}; *hard-coded values for f0=2000
val_EQ1B1[0] = 0xff; val_EQ1B1[1]= 0x53; val_EQ1B1[2]=0x3e; val_EQ1B1[3] =0x72; // B1 {0xff, 0x53, 0x3e, 0x72 };
val_EQ2B1[0] = 0x00; val_EQ2B1[1]= 0x59; val_EQ2B1[2]=0x0a; val_EQ2B1[3] =0x15; // B2 {0x00, 0x59, 0x0a, 0x15 };
val_EQ1A1[0] = 0x00; val_EQ1A1[1]= 0xac; val_EQ1A1[2]=0xc1; val_EQ1A1[3] =0x8e; // A1 {0x00, 0xac, 0xc1, 0x8e };
val_EQ2A1[0] = 0xff; val_EQ2A1[1]= 0xcd; val_EQ2A1[2]=0x26; val_EQ2A1[3] =0x56; // A2 {0xff, 0xcd, 0x26, 0x56 };
i2c_safeload_write_block(Dev_Address, 0x0815, Addr_Filter2_EQ0B1, val_EQ0B1, 4);
i2c_safeload_write_block(Dev_Address, 0x0816, Addr_Filter2_EQ1B1, val_EQ1B1, 4);
i2c_safeload_write_block(Dev_Address, 0x0817, Addr_Filter2_EQ2B1, val_EQ2B1, 4);
i2c_safeload_write_block(Dev_Address, 0x0818, Addr_Filter2_EQ1A1, val_EQ1A1, 4);
i2c_safeload_write_block(Dev_Address, 0x0819, Addr_Filter2_EQ2A1, val_EQ2A1, 4);
set_core_IST_bit(Dev_Address);
}
}
****************** Functions *************************
void i2c_safeload_write_block( int deviceaddress, unsigned int safeload_adr, unsigned int celladdress, byte* data, byte length ) {
unsigned int safeload_data_reg=0x0810;
switch(safeload_adr)
{
case 0x0815: safeload_data_reg=0x0810; break;
case 0x0816: safeload_data_reg=0x0811; break;
case 0x0817: safeload_data_reg=0x0812; break;
case 0x0818: safeload_data_reg=0x0813; break;
case 0x0819: safeload_data_reg=0x0814; break;
}
/* Safeload Data Register (2064 to 2068; 0x0810 TO 0x0814) Write Format*/
Wire.beginTransmission(deviceaddress);
Wire.write((int)(safeload_data_reg >> 8)); // MSB
Wire.write((int)(safeload_data_reg & 0xFF)); // LSB
Wire.write(0x00); //compulsory 0x00
byte c;
for ( c = 0; c < length; c++) Wire.write(data[c]);
Wire.endTransmission();
/* Safeload Address Register (2069 to 2073; 0x0815 TO 0x819 ) Write Format*/
Wire.beginTransmission(deviceaddress);
Wire.write((int)(safeload_adr >> 8)); // MSB
Wire.write((int)(safeload_adr & 0xFF)); // LSB
Wire.write((int)(celladdress >> 8)); // MSB
Wire.write((int)(celladdress & 0xFF)); // LSB
Wire.endTransmission();
}
void set_core_IST_bit(int deviceaddress)
{
/*set the initiate safeload transfer bit ( 5th bit )
in the core control register to initiate the loading into RAM*/
Wire.beginTransmission(deviceaddress);
Wire.write(0x08);
Wire.write(0x1C); //address of DSP core control: 0x081C. Holds 2bytes data.
Wire.write(0x00);
Wire.write(0x3C);
}
Hope to hear from you soon. Thank you very much
Best Regards.
JCB
Hi JCB:
I think there are a couple of problems here. One is the difference in the calculation of the filters between your equations and SigmaStudio. To make sure you can communicate to the DSP correctly using Arduino, I suggest you use the same exact coefficients produced by SigmaStudio for debugging communication issues.
If you are looking into debugging your math calculations, please use the IIR filter type to enter the coefficients that you calculate and then use the stimuly and probe function (built into SigmaStudio) to analyze / understand the response that those coefficients give you. In other words, this is the suggested way to debug your math equations. Consider changing the sign of the a coefficients; this is in many cases is the reazon why filters may behave differently.
The second problem you need to address is how to get safeloading to work To simply debug and test your filters, and to make sure you have communication with the hardware I suggest initially to avoid the use safeload. Instead use direct block writes. This will remove the complexities of having to safeload. Once you are successfully able to write to the part and your coefficients and SigmaStudio calculations agree, then you will be ready to implement safeloading into your Arduino uC.
Please be thorough and patient, your efforts will be rewarded once your system works as expected.
Regards
Miguel
Miguel, thanks for your kindness reply.
I had already tried hard coded the coefficient to be exactly same as capture window and send it to MCU.
The hardware communicate well by using a DSP Readback.
How to confirm that the ADAU1701 have receive my safeload instruction?
I have exactly same data send out as Brett shown in below link.
I have also posted my sample project and programming codes in
Re: Intermittent Safeload failure ADU1701
Anyone could please provide an example in Arduino I2C's safeload integration to control a peaking filter?
Thanks & Regards,
JCB
This question has been assumed as answered either offline via email or with a multi-part answer. This question has now been closed out. If you have an inquiry related to this topic please post a new question in the applicable product forum.
Thank you,
EZ Admin
Please log in to reply.