This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
We'r currently using TLV3210DAC3101 dac in one of our projects. I intend to generate a BEEP sound so as to clear the DAC hardware interface. Iam generating the MCLK from FPGA and feeding it to dac. The wclk and bclk signals will be output from the dac. I have written a initial setup code to be run in u-boot as per the script file mentioned in the TLV3210DAC3101 datasheet. I have attached the setup code also.
My current issue is iam able to hear a faint pop-sound but not able to hear any beep when i run the code in uboot. I have ensured all the registers are written with the correct values. I request the support the team to kindly review the setup code and let me know if any step is being missed.
/*DAC register setting implementation implementation * Function name :DAC TLV320DAC3101 related * By:Vikram.R * Description :This code is used for register setting of TLV320DAC3101 * Mode:Master, Codec interface: i2s, Word length: 16, MCLK of 16MHz and DIN given from FPGA * */ #include <common.h> #include <command.h> #include <i2c.h> #define DAC_I2C_ADDR 0x18 #define DAC_SW_RESET 0x01 #define PLL_CLKIN_CODEC_CLKIN 0x03 #define PLL_POWER_P_R 0x91 #define DAC_PLLJ 0x05 #define DAC_D_MSB 0x0E #define DAC_D_LSB 0xB0 #define DAC_NDAC 0x82 #define DAC_MDAC 0x87 #define DAC_DOSR_MSB 0x00 #define DAC_DOSR_LSB 0x80 #define DAC_CODEC_IF_CNTRL 0x0l #define DAC_PRB_SELECT 0x19 void dac_i2c_write(uchar , uchar); void dac_tisbc_setup() { dac_i2c_write(0x0, 0x0); /*Set register page to 0*/ dac_i2c_write(0x1, DAC_SW_RESET); /*Initiate SW reset (PLL is powered off as part of reset)*/ dac_i2c_write(0x4, PLL_CLKIN_CODEC_CLKIN); /*PLL_clkin = MCLK,codec_clkin = PLL_CLK*/ dac_i2c_write(0x5, PLL_POWER_P_R);/*PLL Power up, P = 1, R = 1 */ dac_i2c_write(0x6, DAC_PLLJ);/*J = 5*/ dac_i2c_write(0x7, DAC_D_MSB);/*D=3760=>0x0EB0*/ dac_i2c_write(0x8, DAC_D_LSB);/*D=3760=>0x0EB0*/ dac_i2c_write(0x0B,DAC_NDAC);/*NDAC is powered up and set to 2*/ dac_i2c_write(0x0C,DAC_MDAC);/*MDAC is powered up and set to 7*/ dac_i2c_write(0x0D,DAC_DOSR_MSB);/*DOSR MSB is 0*/ dac_i2c_write(0x0D,DAC_DOSR_LSB);/*DOSR LSB is 0x80 => DOSR value is 128*/ dac_i2c_write(0x1B,0x0C);/*mode is i2s, wordlength is 16, master mode*/ dac_i2c_write(0x3C, 0x19); /*select processing block PRB_P25*/ dac_i2c_write(0x00, 0x08); /*Select Page 8*/ dac_i2c_write(0x01, 0x04); /*Adaptive filtering anabled in DAC processing block*/ dac_i2c_write(0x00, 0x00); /*Change to page 0 */ /* BEEP Settings*/ dac_i2c_write(0x47,0x83); /* vol of -1dB Left */ dac_i2c_write(0x48, 0x43);/* vol of -1dB Right*/ dac_i2c_write(0x49, 0x03);/*BEEP length MSB*/ dac_i2c_write(0x4A, 0xC9);/*BEEP length Middle*/ dac_i2c_write(0x4B, 0x80);/*BEEP length LSB*/ dac_i2c_write(0x4C, 0x10);/*Sine Coeff*/ dac_i2c_write(0x4D, 0xD8);/*Sine Coeff*/ dac_i2c_write(0x4E, 0x7E);/*Cosine Coeff*/ dac_i2c_write(0x4F, 0xE3);/*Cosine Coeff*/ dac_i2c_write(0x74, 0x80);/*volume control thru pin enable*/ /*Program analog blocks*/ dac_i2c_write(0x00, 0x01);/*Set register page to 1*/ dac_i2c_write(0x1F, 0x04);/*Program common-mode voltage (defalut = 1.35 V) */ dac_i2c_write(0x21, 0x4E);/*De-pop, Power on = 800 ms, Step time = 4 ms */ dac_i2c_write(0x23, 0x44);/*LDAC routed to HPL out, RDAC routed to HPR out*/ dac_i2c_write(0x28, 0x06);/*Unmute HPL, set gain = 0 db*/ dac_i2c_write(0x29, 0x06);/*Unmute HPR, set gain = 0 dB*/ dac_i2c_write(0x2A, 0x1C);/*Unmute Class-D Left, set gain = 18 dB*/ dac_i2c_write(0x2B, 0x1C);/*Unmute Class-D Right, set gain = 18 dB*/ /*Power up output drivers*/ dac_i2c_write(0x1F, 0xC2);/*HPL and HPR powered up*/ dac_i2c_write(0x20, 0xC6);/*Power-up Class-D drivers*/ dac_i2c_write(0x24, 0x92);/*Enable HPL output analog volume, set = -9 dB*/ dac_i2c_write(0x25, 0x92);/*Enable HPR output analog volume, set = -9 dB*/ dac_i2c_write(0x26, 0x92);/*Enable Class-D Left output analog volume, set = -9 dB*/ dac_i2c_write(0x27, 0x92);/*Enable Class-D Right output analog volume, set = -9 dB*/ /*Power up DAC*/ dac_i2c_write(0x00, 0x00); dac_i2c_write(0x3F, 0xD4);/*Powerup DAC left and right channels (soft step enabled)*/ dac_i2c_write(0x41, 0xD4);/*DAC Left gain = -22 dB*/ dac_i2c_write(0x42, 0xD4);/*DAC Right gain = -22 dB*/ dac_i2c_write(0x40, 0xD4);/*Unmute DAC left and right channels*/ /**/ } void dac_i2c_write(uchar reg, uchar val) { uchar *buf; buf = &val; i2c_write(DAC_I2C_ADDR, reg, 0x0, buf, 0x01); i2c_read(DAC_I2C_ADDR, reg, 0x0, buf, 0x01); printf("\n Value %s written at register %s ", *buf, reg); }
Regards,
Vikram.R
Hello Luis Fernando Rodríguez,
Thanks for the reply.
I am not getting any output on BCLK and WCLK even though I have set these clocks to be output from the DAC. I am giving 48Mhz MCLK clock from FPGA to DAC(verified using oscilloscope ) and a sampling frequency is set as 48KHz. I am trying to drive HPL/HPR output. I am able to read and write I2C registers from uboot. So DAC register access is not an issue. Please let me know if anything I have missed.
P.S: Register settings file is attached in previous post.
Regards,
Vikram.R
Senior Engineer
Bharat Electronics Limited
Hello Luis,
Thanks for the reply. I had mentioned wrongly that MCLK is 48Mhz, wherein it was 16Mhz(and values according to table 5-28 of the datasheet). Nevertheless I tried using 48Mhz and values you had mentioned. Still the issue remains the same. Is there anything else I can check ? Thanks for the support.
Regards,
Vikram.R
Senior Engineer
Bharat Electronics Limited
Dear Rodríguez,
Thanks for the info. I have enabled the clock register 0x1d and set the divider value as 1 in register 0x1e of page 0. Still the issue remains. Please let me know if any other parameters ,hardware/software, I need to check.
Thanks for your prompt responses.
P.S: I feel the script file in the datasheet can be updated to include the above two register settings mentioned by you.
Regards,
Vikram.R
Hi, Vikram,
Could you try with the following script? It is a complete example script that contains all the configuration of the TLV320DAC3101. I modified the PLL and Beep values in order to adapt it to your code.
# Key: w 30 XX YY ==> write to I2C address 0x30, to register 0xXX, data 0xYY # # ==> comment delimiter # # The following list gives an example sequence of items that must be executed in the time # between powering the # device up and reading data from the device. Note that there are # other valid sequences depending on which features are used. # 1. Define starting point: # (a) Power up applicable external hardware power supplies # (b) Set register page to 0 # w 30 00 00 # # (c) Initiate SW reset (PLL is powered off as part of reset) # w 30 01 01 # # 2. Program clock settings # (a) Program PLL clock dividers P, J, D, R (if PLL is used) # # PLL_clkin = MCLK,codec_clkin = PLL_CLK w 30 04 03 # J = 5 w 30 06 05 # D = 3760, D(13:8) = 0x0E, D(7:0) = 0xB0 w 30 07 0E B0 # # (b) Power up PLL (if PLL is used) # PLL Power up, P = 1, R = 1 # w 30 05 91 # # (c) Program and power up NDAC # # NDAC is powered up and set to 2 w 30 0B 82 # # (d) Program and power up MDAC # MDAC is powered up and set to 7 w 30 0C 87 # # (e) Program OSR value # # DOSR = 128, DOSR(9:8) = 0, DOSR(7:0) = 128 w 30 0D 00 80 # # (f) Program I2S word length if required (16, 20, 24, 32 bits) # and master mode (BCLK and WCLK are outputs) # # mode is i2s, wordlength is 16, master mode w 30 1B 0C # BDIV_CLKIN = DAC_MOD_CLk; BCLK & WCLk active W 30 1D 05 # BCLK_N = 2 w 30 1E 82 # # (g) Program the processing block to be used # # Select Processing Block PRB_P25 w 30 3C 19 w 30 00 08 w 30 01 04 w 30 00 00 # # (h) Miscellaneous page 0 controls # # DAC => volume control thru pin disable w 30 74 00 # 3. Program analog blocks # # (a) Set register page to 1 # w 30 00 01 # # (b) Program common-mode voltage (defalut = 1.35 V) # w 30 1F 04 # # (c) Program headphone-specific depop settings (in case headphone driver is used) # # De-pop, Power on = 800 ms, Step time = 4 ms w 30 21 4E # # (d) Program routing of DAC output to the output amplifier (headphone/lineout or speaker) # # LDAC routed to HPL out, RDAC routed to HPR out w 30 23 44 # # (e) Unmute and set gain of output driver # # Unmute HPL, set gain = 0 db w 30 28 06 # Unmute HPR, set gain = 0 dB w 30 29 06 # Unmute Class-D Left, set gain = 18 dB w 30 2A 1C # Unmute Class-D Right, set gain = 18 dB w 30 2B 1C # # (f) Power up output drivers # # HPL and HPR powered up w 30 1F C2 # Power-up Class-D drivers w 30 20 C6 # Enable HPL output analog volume, set = -9 dB w 30 24 92 # Enable HPR output analog volume, set = -9 dB w 30 25 92 # Enable Class-D Left output analog volume, set = -9 dB w 30 26 92 # Enable Class-D Right output analog volume, set = -9 dB w 30 27 92 # # 4. Apply waiting time determined by the de-pop settings and the soft-stepping settings # of the driver gain or poll page 1 / register 63 # # 5. Power up DAC # (a) Set register page to 0 # w 30 00 00 # # (b) Power up DAC channels and set digital gain # # Powerup DAC left and right channels (soft step enabled) w 30 3F D4 # # DAC Left gain = -22 dB w 30 41 D4 # DAC Right gain = -22 dB w 30 42 D4 # # (c) Unmute digital volume control # # Unmute DAC left and right channels w 30 40 00 # # Beep settings w 30 00 00 w 30 47 03 w 30 48 43 w 30 49 03 w 30 4A C9 w 30 4B 80 W 30 4C 10 W 30 4D D8 W 30 4E 7E W 30 4F E3 # Enable Beep w 30 47 83
Best regards,
Luis Fernando Rodríguez S.
Hello Rodriguez,
Thanks for the script file. I will try it and let you know the status.
Regards,
Vikram.R
Hello Luis,
I have tried both '0' and '1' for Page 0 / Register 116 / Bit D7. Still iam not able to hear any beep sound.
By coefficient registers , I meant the page 8 coefficient registers for Buffers.
I feel in software only Iam missing some register settings. Is there any other registers I have to initialize ?
Regards,
Vikram.R