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.

TAS5806MD: Set Biquad coefficents via I2C

Part Number: TAS5806MD
Other Parts Discussed in Thread: TAS5806M

Hello,

I am trying to set the BQ coefficients of my TAS5806MD via an STM32 programmed in Cube IDE. For some testing I try to set a simple lowpass. The Problem is, that it doesn't affect the sound, so the signal is not lowpassed. I couldn't figure how to get it working. Do I need to write 0x00 to the BQ_WR_CTRL1 Register? I really dont have any clue.

my code here step by step:

1) Power Up and then send 0x02 to the DEVICE_CTRL_2_REGISTER for HiZ Mode
2) Wait for 10ms
3) Convert coefficient into 5.27 Format (for example -1.98611414 is converted into 4 bytes --> 1st Byte: 141   2nd Byte: 224   3rd Byte: 176    4th Byte: 214)
4) go to Page 0x00
5) change to Book 0xAA
6) go to Page 0x26
7) select subadress (for example 0x54 for Right BQ1 B0)
8) send the precalculated 4 bytes of the coefficient (1st Byte: 141   2nd Byte: 224   3rd Byte: 176    4th Byte: 214)
9) do 3)-8) again for the remaining 4 BQ coefficents.
9) go to Page 0x00
10) change to Book 0x00
11) send 0x03 to the DEVICE_CTRL_2_REGISTER for Play Mode

Am I missing any steps? Is the 5.27 Format right? could you provide me an example pseudo code or a step by step example how to set the Registers of the DSP of the TAS5806MD right? 

Best regards,
Severin

  • Hello Luis,

    thanks for your reply! I will check if the fromating is the same like the one provided in the link.
    In the meantime could you tell me if I need to set the BQ_WR_CTRL1 Register and if, except for the formating of the coefficients, the sequence of my programm is right?

    Best regards,
    Severin

  • Hello Severin,

    The sequence looks correct. You shouldn't need to update that BQ register, mainly for reading to see when the biquad is updating.

    Best regards,

    Luis

  • Hello Luis,

    I checked my formating in the code and it was not the same as the one in your provided link. I now updated the code and it looks like this:

    int float_to_Q_format_int(float floating_Num, char format[]){
    	int q_num = 0;
    
    	if(strcmp(format,"1.31")==0){
    			q_num = round(floating_Num*pow(2,31));
    	}
    	else if(strcmp(format,"2.30")==0){
    			q_num = round(floating_Num*pow(2,30));
    	}
    	else if(strcmp(format,"5.27")==0){
    			q_num = round(floating_Num*pow(2,27));
    	}
    	else if(strcmp(format,"9.23")==0){
    			q_num = round(floating_Num*pow(2,23));
    	}
    
        //if float number is negative convert positive integer from above into negative twos compliment 
    	if (floating_Num < 0){
    		q_num = abs(q_num); //Magnitude of qnum
    		q_num = ~q_num; 	//bitwise inverting
    		q_num += 1; 		//adding +1 for negative twos compliment
    	}
    	return q_num;
    }
    
    //convert the int number into 4 single bytes
    uint8_t *int_to_4_bytes(int int_Num){
    	uint8_t *byte_Array = malloc(4);
    	byte_Array[0]= (int_Num & 0xff000000) >> 24; //msB --> index 0
    	byte_Array[1]= (int_Num & 0x00ff0000) >> 16;
    	byte_Array[2]= (int_Num & 0x0000ff00) >> 8;
    	byte_Array[3]= (int_Num & 0x000000ff); //lsB --> index 3
    	return byte_Array;
    }

    But still there is no effect on the output.

    I calculted my BQ lowpass coefficients on this website: https://www.earlevel.com/main/2013/10/13/biquad-calculator-v2/

    What could be wrong with my code?

  • Hello Severin,

    Are you able to read back the values configured in that biquad to confirm it's configured properly?

    best regards,

    Luis

  • Hello Luis,

    Yes i have read the values and they seem to be correct. Now I also tried to set the first BQ for the left channel and suddenly the output on both channels was very very low. This are my coefficients with normalization applied:

                            //calculate the coefficients like in the Process Flow suggested: {b0,b1/2,b2,a1/(-2),a2/(-1)}           
    float BQ_1_values [5] = {0.0002616518014479815,0.000523303602895963/2,0.0002616518014479815,-1.9537212766076175/(-2),0.9547678838134095/(-1)};
    

    When I set them on the right first biquad nothing happens at all, but when I set them on the left first biquad both channels only have a very low output signal. 

    The Register values in decimal are:

    Right 1st Biquad:
    b0: 0    0    137    46
    b1: 0    0    137    46
    b2 :0    0    137    46
    a1: 7    208    156    80
    a2: 248    92    162    168
    
    Left 1st Biquad:
    b0: 0    0    137    46
    b1: 0    0    137    46
    b2 :0    0    137    46
    a1: 7    208    156    80
    a2: 248    92    162    168

    Any Idea? Am I calculating the BQ coefficents wrong? Also could you give me access to the TAS5806M EVM App for PPC3?

    Best regards,
    Severin

  • Hello Severin,

    May you submit the request from ti.com, then i will enable the access to App.

    Dylan

  • Hello Dylan, 

    thank you for your response, I submitted a request. But could you also tell me if the coefficients are converted right from float to 5.27 Q format or not? I am still having the same problem and I can't find any more information on the Interent.

    It would be really nice if someone who managed to set the coefficents right could help me. Looking forward to any help.

    Best regards,
    Severin

  • Hello Severin, 

    I provided access to the TAS5806MD software, refer to the coefficients in the equalizer tab to verify your conversion. 

    best regards.

    Luis

  • Hello Luis,

    I checked the values in PPC3 now and they seem to be the same so I can't really tell why it is not working. When I do not do the pre calculation like b0, b1/2, b2, a1/(-2), a2/(-1) the amplifier outputs a white noise like signal and draws abot 3 times the current it usually does. If I set the registers with pecalculted values the output just gets very silent. 
    PPC3 doesn't do the preclaculation but it is in the Process flow sheet so what should I do now?


    Why does PPC3 wirte 0x18 (marked with yellow) before biquads are written?

    Best regards,
    Severin

  • Hello Severin,

    Can you readback register 0x66 on Page0,Book0. Additionally can you add w 58 66 86 to your write sequence before writing to the biquad.

    The 0x18 is the start of the address for that first biquad because it's a multibyte write as you can see the format of the i2c write.

    best regards,

    Luis

  • Hello Luis,

    I finally managed to set registers successfully. The lowpass can be heard very well. I am posting my solution for everyone who is reading this:

    here is the sequence beginning after turning on the power supplies (PVDD, DVDD)

    0) set PDN High, wait for 10ms, start I2S, start I2C
    1) w 58 03 02  (set into HiZ)
    2) w 58 66 8e  (I used 8e so that left and right channel can have individual BQ coeff.)
    3) wait for 10ms
    4) w 58 00 00  (go to page 00)
    5) w 58 7f  aa  (go to book AA for the BQ filters coefficents)
    6) w 58 00 26  (go to subadress 26 for the first BQ coef of the right channel) 
    7) w 58 54 xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx (write all 20 Bytes of the 5 BQ coeff to the subadress of the first coeff -> B0 of right channel)
    8) w 58 00 00  (go to page 00)
    9) w 58 7f 00   (go back to book 00 in order to set the basic registers listed in the datasheet)
    10) w 58 03 03 (set into Play mode)

    I hope this helps. My mistake was that i forgot to write 2)  and also that i didn't write 7) in one process (insted, after I transmitted 4 bytes of one BQ coeff. I wrote the next subadress. But that was wrong because it is only necessary to write the subadress of the first BQ coeff once. and then transmit all BQ coeff.)

    This thread can be closed now.

    Best regards,

    Severin