Hi All,
I am using the EVM5517 development board for developing an active noise control device. For this application, I need to be able to read and write audio to both of the codecs simultaneously. I read previous forum topics on this problem, as well as I researched the available schematics and code examples, however, I did not manage to make it work yet.
I am using the example codes from Spectrum Digital, specifically the AIC3204_1 and AIC 3204_2 example codes.
As I know, this problem is tricky, since both codecs use the same i2c address. I also found that it is possible as the i2c can be routed both codecs through a two pairs of diodes as presented page B-6 on the Spectrum Digital Technical document schematics.
My understanding is that I can select the I2C_SCL_BOTH and I2C_SDA_BOTH scenarios by adjusting the SEL_I2C_S0 and SEL_I2C_S1 parameters in the software through the p02 and p03 routes.
However when I modify these parameters selecting them either high or low in any combination, it still does not give me the desired goal.
In my trials, I modified the aic3204_test.c as:
//----------------------------------- Codec 1 -------------------------------------------------- /* Configure Serial Port 0 */ SYS_EXBUSSEL &= ~0x0300; // SYS_EXBUSSEL |= 0x0100; // Serial Port mode 1 (I2S1 and GP[11:10]). /* Configure I2C mux for AIC3204-1 */ EVM5517_I2CGPIO_configLine( 2, 0 ); //EVM5517_I2CGPIO_writeLine( 2, 0 ); // SEL _I2C_S0 = 0 --> required for codec-1 EVM5517_I2CGPIO_writeLine( 2, 1 ); // SEL_I2C_S0 = 1 ---> required for codec2 // required for both codec 1 and codec 2 ??? EVM5517_I2CGPIO_configLine( 3, 0 ); EVM5517_I2CGPIO_writeLine( 3, 0); // SEL_I2C_S1 = 0 /* Set AIC_MCBSP_MODE to I2S (disable McBSP) */ EVM5517_I2CGPIO_configLine( 1, 0 ); EVM5517_I2CGPIO_writeLine( 1, 1 ); // AIC_MCBSP_MODE = 1 /* Set SEL_MMC0_I2S to I2S */ EVM5517_I2CGPIO_configLine( 8, 0 ); EVM5517_I2CGPIO_writeLine( 8, 1 ); // SEL_MMC0_I2S = 1 /* Release AIC3204 reset */ EVM5517_I2CGPIO_configLine( 0, 0 ); EVM5517_I2CGPIO_writeLine( 0, 0 ); // AIC_RST = 0 // --------------------------------------Codec 2 ---------------------------------------------- /* Configure Serial Port 0 */ SYS_EXBUSSEL &= ~0x7300; // SYS_EXBUSSEL |= 0x4100; // Enable I2S2 pins // -> these commented out are performed with codec-1 /* Configure I2C mux for AIC3204-2 */ //EVM5517_I2CGPIO_configLine( 2, 0 ); //EVM5517_I2CGPIO_writeLine( 2, 1 ); // SEL_I2C_S0 = 1 //EVM5517_I2CGPIO_configLine( 3, 0 ); //EVM5517_I2CGPIO_writeLine( 3, 0 ); // SEL_I2C_S1 = 0 EVM5517_I2CGPIO_configLine( 4, 0 ); EVM5517_I2CGPIO_writeLine( 4, 0); // HPI_ON = 0 /* Configure SPI2 mux for AIC3204-2 */ EVM5517_I2CGPIO_configLine( 5, 0 ); EVM5517_I2CGPIO_writeLine( 5, 1 ); // SPI_I2S2_S0 = 1 EVM5517_I2CGPIO_configLine( 6, 0 ); EVM5517_I2CGPIO_writeLine( 6, 1 ); // SPI_I2S2_S1 = 1 /* Release AIC3204 reset */ EVM5517_I2CGPIO_configLine( 0, 0 ); EVM5517_I2CGPIO_writeLine( 0, 0 ); // AIC_RST = 0 // ----------------------------------------- end of codec 2 ----------------------------------------------------
I focused on modifying the following lines which I believe adjust the SEL_i2c_S0,S1 parameters:
EVM5517_I2CGPIO_writeLine( 2, 0 or 1 ) , EVM5517_I2CGPIO_writeLine( 3, 0 or 1 )
I also modified the aic3204_loop_stereo_in1.c to enable both I2S0 and I2S2 pins:
/* I2S settings */ I2S0_SRGR = 0x0015; I2S0_ICMR = 0x0028; // Enable interrupts I2S0_CR = 0x8012; // 16-bit word, Master, enable I2S /* I2S settings */ I2S2_SRGR = 0x0015; I2S2_ICMR = 0x0028; // Enable interrupts I2S2_CR = 0x8012; // 16-bit word, Master, enable I2S
then I am trying to read and write to the two I2S channels by:
while((Rcv & I2S2_IR) == 0); // Wait for receive interrupt to be pending
data1[sample] = I2S2_W0_MSW_R; // 16 bit left channel received audio data
data2[sample] = I2S2_W1_MSW_R; // 16 bit right channel received audio data
while((Xmit & I2S0_IR) == 0); // Wait for receive interrupt to be pending
I2S0_W0_MSW_W = data1[sample]; // 16 bit left channel transmit audio data
I2S0_W1_MSW_W = data2[sample]; // 16 bit right channel transmit audio data
when p02 =0 and p03 = 0, only codec 1 works. when p02 =1 and p03 =0 only codec 2 works.
p02 = 1 and p03 =1 does not give me the desired scenario, whereI can read and write on both codecs.
How do I need to modify the code or the hardware to achieve my goal. Please help me what am I missing!
Thank you very much for your help in advance!
Best regards,
Gergely Orosz