xmos mic array headphone amp gain control during streaming

If you have a simple question and just want an answer.
shaileshwankhede
Experienced Member
Posts: 65
Joined: Fri Dec 02, 2016 1:30 pm

xmos mic array headphone amp gain control during streaming

Post by shaileshwankhede »

Hi,
I am using app_usb_aud_mic_array[sw_usb_audio - usb_audio6.15.2] as base firmware for further devlopment. I am able to control headphone amplifier(CS43L21 mounted on board) gain by writing fairly simple code in AudioHwConfig()

Code: Select all

/*Set DAC gain*/
val = 0b11100000;    // 111 -> required gain value
DAC_REGWRITE(8, val);
DAC_REGREAD_ASSERT(8, data, val);
But this happens only once on bootup. I want to control volume based on user interaction. For this I am trying to put similar code for button cases A & D in user_pdm_process() but its failing at DAC_REGREAD_ASSERT once stream started. Its always going to assert means I2C_write is not successful. I am not getting where it's going wrong.
PS. Since I was getting compilation errors like (multiple definition, parallel usage) accessing struct r_i2c and p_gpio in pdm_user.xc, I implemented below way in pdm_user.xc:

Code: Select all

on tile[0] : struct r_i2c _r_i2c = {XS1_PORT_4E};
on tile[0] : out port _p_gpio = XS1_PORT_4F;
#define DAC_REGWRITE(reg, val) {data[0] = val; i2c_master_write_reg(0x4a, reg, data, 1, _r_i2c);}
#define DAC_REGREAD_ASSERT(reg, data, expected) {data[0] = 0xAA; i2c_master_read_reg(0x4a, reg, data, 1, _r_i2c); assert(data[0] == expected);}
Then compilation error goes away but still not able to control gain this way.

What's wrong over here? I can share complete edited source if required.

Thanks,
Shailesh
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

I'd say the compilation errors were because user_pdm_process is on tile 0, while the I2C ports it's now trying to write to are on tile 1