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.

TAS3251: TAS3251 DSP

Part Number: TAS3251

i have a question and i will be grateful if you can help me.
main project: connecting STM32H743 to TAS3251 and playing an mp3 file saved on a usb flash which is connected to stm32.
problem: cant get dsp to work. (tas3251 plays the song also i can change its volume by 0x3d and 0x3e but i cant get the dsp to work)

what i have done up to now:
i decode the mp3 file on the usb flash connected to stm32. i connect the i2s pins of stm32 to the ta3251 (4 wires- i also generate the MCLK) and i play the music successfully. also i can change the volume by varying the number written for 0x3d and 0x3e. i send you the TAS3251_init function which i wrote up to now:

void TAS3251_LoadRegisters(const cfg_reg *r, uint16_t size)
{
    for(uint16_t i=0;i<size;i++)
    {
        HAL_I2C_Mem_Write(&hi2c3,TAS_ADDR,r[i].reg,I2C_MEMADD_SIZE_8BIT,(uint8_t*)&r[i].val,1,HAL_MAX_DELAY);
        HAL_Delay(1);
    }
}

cfg_reg registers[] = {
//program memory
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x02, 0x11 },      //PowerDown DSP. Bit 0 not documented
    { 0x01, 0x11 },   //Reset module & registers. Bits are auto cleared
    { 0x00, 0x00 },   //Wait
    { 0x00, 0x00 },
    { 0x00, 0x00 },
    { 0x00, 0x00 },
    { 0x03, 0x11 },   //Mute L&R
    { 0x2a, 0x00 },   //Zero Data path L&R (= mute...)
    { 0x25, 0x18 },   //Ignore MCLK error detection
    { 0x0d, 0x00 },   //Clck config..

    { 0x28, 0x00 },      //I2S config
    { 0x29, 0x01 },

    { 0x02, 0x00 },   //Wake up DSP

//Sample rate update
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x02, 0x80 },   //Reset DSP

    { 0x00, 0x00 },
    { 0x7f, 0x00 },

// speed 03-48k 04-96k
//dynamically reading speed
    { 0x22, 0x03 },   //Set FS Speed. Ignored in auto clock mode

    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x02, 0x00 },   //Restart DSP
//register tuning
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x00, 0x00 },
    { 0x07, 0x00 },
    { 0x08, 0x20 },
    { 0x55, 0x07 },
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x00, 0x00 },
    { 0x3d, 0x50 },     //volume
    { 0x3e, 0x50 },     //volume
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x00, 0x01 },
    { 0x02, 0x00 },

//Unmute the device
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x03, 0x00 },
    { 0x2a, 0x11 },

};

my problem starts from here. i want to start dsp and change the volume by the value written for 0x44 and 0x48 register which are on page 0x8c .
when i change the value of 0x44 and 0x48 nothing happens (the volume doesn't change) for example when i change it to 0 i expect the sound to be muted but it doesn't happen.
i send you the second init function which i wrote to get the dsp to work:


cfg_reg registers[] = {
//program memory
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x02, 0x11 },      //PowerDown DSP. Bit 0 not documented
    { 0x01, 0x11 },   //Reset module & registers. Bits are auto cleared
    { 0x00, 0x00 },   //Wait
    { 0x00, 0x00 },
    { 0x00, 0x00 },
    { 0x00, 0x00 },
    { 0x03, 0x11 },   //Mute L&R
    { 0x2a, 0x00 },   //Zero Data path L&R (= mute...)
    { 0x25, 0x18 },   //Ignore MCLK error detection
    { 0x0d, 0x00 },   //Clck config..

    { 0x28, 0x00 },      //I2S config
    { 0x29, 0x01 },

    { 0x02, 0x00 },   //Wake up DSP

//Sample rate update
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x02, 0x80 },   //Reset DSP

    { 0x00, 0x00 },
    { 0x7f, 0x00 },

// speed 03-48k 04-96k
//dynamically reading speed
    { 0x22, 0x03 },   //Set FS Speed. Ignored in auto clock mode

    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x02, 0x00 },   //Restart DSP

    //write co-efficients

        { 0x00, 0x00 },    //Change Page
        { 0x7f, 0x8c },
        { 0x00, 0x1e },    //Page 0x1e
        { 0x44, 0x00 },    //VOLUME CONTROL - CH-L Volume
        { 0x45, 0x00 },
        { 0x46, 0x00 },
        { 0x47, 0x00 },

        { 0x00, 0x00 },    //Change Page
        { 0x7f, 0x8c },
        { 0x00, 0x1e },    //Page 0x1e
        { 0x48, 0x00 },    //VOLUME CONTROL - CH-R Volume
        { 0x49, 0x00 },
        { 0x4a, 0x00 },
        { 0x4b, 0x00 },

    //swap command
        { 0x00, 0x00 },
        { 0x7f, 0x8c },
        { 0x00, 0x23 },
        { 0x14, 0x00 },
        { 0x15, 0x00 },
        { 0x16, 0x00 },
        { 0x17, 0x01 },

//register tuning
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x00, 0x00 },
    { 0x07, 0x00 },
    { 0x08, 0x20 },
    { 0x55, 0x07 },
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x00, 0x00 },
    { 0x3d, 0x50 },
    { 0x3e, 0x50 },

    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x00, 0x01 },
    { 0x02, 0x00 },

//Unmute the device
    { 0x00, 0x00 },
    { 0x7f, 0x00 },
    { 0x03, 0x00 },
    { 0x2a, 0x11 },

};

what can i do in this case.Thanks for attention.

  • Hi Mohammad,

    The issue seems to be with your swap command, ensure that you go to page 0x05 and use the swap flag as shown in the datasheet.

    Alternatively, I would suggest using PPC3 to generate these commands and avoid any accidental miscalculation or error in register writes.

    Regards,

    Isaac

  • Hi Isaac. as mentioned in this link : (https://e2e.ti.com/support/audio-group/audio/f/audio-forum/1571027/tas3251-coefficient-swap-flag?tisearch=e2e-sitesearch&keymatch=tas3251%20swap# ) the swap command in the datasheet is incorrect and the correct one is as i wrote: 

     //swap command
            { 0x00, 0x00 },
            { 0x7f, 0x8c },
            { 0x00, 0x23 },
            { 0x14, 0x00 },
            { 0x15, 0x00 },
            { 0x16, 0x00 },
            { 0x17, 0x01 },

    i wrote this swap command after setting the volume in the dsp registers. but it didnt work.

    in the first step i want to write a very simple code to test whether the DSP is working or not. (i dont want to set BQ, ... in this step).

  • Hi Mohammad,

    It looks like you are trying to set the volume to minimum level of -110dB, to do this you must write the value '1b' to registers 0x47 and 0x4b. Right now you are writing '00' to these registers which does not correspond to a volume level. I've included a code snipped below for this from the PPC3 I2C Monitor:

    You can use the I2C monitor to see how changes made in PPC3 will be written in I2C and see which register values the changes correspond to.

    Regards,

    Isaac

  • Hi Isaac,
    Ok, as you wrote i changed the values of registers 0x47 and 0x4b to 0x1b. but again the output volume didn't change.
    i did these test:
    first, i played a single frequency sinewave.mp3 using basic registers of tas3251.i checked the output with the oscilloscope and i measured the peak to peak voltage of the output. i saw that when i change the value of registers 0x3d and 0x3e (which are amplifiers main registers) the peak to peak voltage of the output changed. which means that amplifier is working and i can successfully write in its main registers.
    in the second test, i wrote the initialization function using the main registers+ DSP registers (i sent you the code in the previous messages). again i measured the peak to peak voltage of the output. Then, i changed the value of registers 0x44 and 0x48 (which are the registers to change the volume with DSP). and i saw that the peak peak to peak voltage of the output doesn't change with varying these registers values. (which means that the signal is not going through the DSP and it is routed to the output just going through the main amplifier). 

  • Hi Mohammad,

    Can you try using PPC3 to generate these register values? It is the preferred method for device initialization. You can make any DSP changes necessary and then use the 'End System Integration' section to create a cfg file.

    Regards,

    Isaac