ΣSigmaStudio Ask AI Русский Log in

Sound distortion when loading registers from STM32

SigmaDSP & SigmaStudio Alekssandr Nov 9, 2018 00:00 4 replies Original on forum ↗
Subscribe
Alekssandr Question
Nov 9, 2018 00:00

Good day!

I use the STM32F303RC microcontroller, DSP ADAU1452 (xtal 24.576) in conjunction with the ADAU1962A DAC (clocked with DSP).

The compiled project in SigmaStudio placed in the STM32 memory and after the microcontroller restarted, the firmware and registers are loaded into the DSP memory via the I2C bus (400kHz speed), but sometimes there is a strong distortion of the sound on the DAC output, noticed that the problem is corrected after enabling and disabling 0xF003 PLL Enable register. Sometimes it has to be done 2 or more times.

I can not deal with this problem for more than a month, I tried everything. I changed the speed of I2C to the minimum values, made a check of the recorded registers in the DSP, did everything written in ADAU1452, but this problem does not go away. I ask for advice what could be the problem? Or is it possible to somehow determine that something is wrong with the PLL?

Thank! I will be glad to any advice!

PS when using the SELFBOOT mode this problem is not present, always loaded with a normal sound.

Attached a video with the problem and the project file in SigmaStudio

DIXOM.rar

PLL lock check function

void initDspVerifityPLL(){

SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_SOFT_RESET_DSP_ADAU1452_ADDR, REG_SOFT_RESET_DSP_ADAU1452_BYTE, &R0_SOFT_RESET_DSP_ADAU1452_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_SOFT_RESET_DSP_ADAU1452_ADDR, REG_SOFT_RESET_DSP_ADAU1452_BYTE, &R1_SOFT_RESET_DSP_ADAU1452_Default );

osDelay(10);

uint8_t result[2];
short regStatus = 0;

for( short StatusPll=0; StatusPll<10; StatusPll++ ){

readFromDSP( REG_PLLLOCKED_DSP_ADAU1452_ADDR, 2, &result);
if( result[0] != 0 || result[1] != 1 || regStatus == 1 ){

SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_PLL_ENABLE_DSP_ADAU1452_ADDR, 2, &R8_PLL_ENABLE_DSP_ADAU1452_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_PLL_CTRL0_DSP_ADAU1452_ADDR, 2, &R9_PLL_CTRL0_DSP_ADAU1452_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_PLL_CTRL1_DSP_ADAU1452_ADDR, 2, &R10_PLL_CTRL1_DSP_ADAU1452_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_PLL_CLK_SRC_DSP_ADAU1452_ADDR, 2, &R11_PLL_CLK_SRC_DSP_ADAU1452_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_MCLK_OUT_DSP_ADAU1452_ADDR, 2, &R12_MCLK_OUT_DSP_ADAU1452_Default );
SIGMA_WRITE_REGISTER_BLOCK( DEVICE_ADDR_DSP_ADAU1452, REG_PLL_ENABLE_DSP_ADAU1452_ADDR, 2, &R13_PLL_ENABLE_DSP_ADAU1452_Default );
regStatus = 0;
osDelay(20);
}
else{
readFromDSP( REG_PLL_CTRL0_DSP_ADAU1452_ADDR, 2, &result); if( result[0] != 0 || result[1] != 96) { regStatus = 1; }
readFromDSP( REG_PLL_CTRL1_DSP_ADAU1452_ADDR, 2, &result); if( result[0] != 0 || result[1] != 3 ) { regStatus = 1; }
readFromDSP( REG_PLL_CLK_SRC_DSP_ADAU1452_ADDR, 2, &result); if( result[0] != 0 || result[1] != 1 ) { regStatus = 1; }
readFromDSP( REG_MCLK_OUT_DSP_ADAU1452_ADDR, 2, &result); if( result[0] != 0 || result[1] != 5 ) { regStatus = 1; }
readFromDSP( REG_PLLWATCHDOG_DSP_ADAU1452_ADDR, 2, &result); if( result[0] != 0 || result[1] != 1 ) { regStatus = 1; }
readFromDSP( REG_PLL_ENABLE_DSP_ADAU1452_ADDR, 2, &result); if( result[0] != 0 || result[1] != 1 ) { regStatus = 1; }

if(regStatus==0){
StatusPll = 40;

Init_DAC_ADAU1962();
//Init_DAC_AK4458VN();
Init_DSP_ADAU1452();
InitDspSerialInput();
}
}
}
}

Audio Signal Processors

adau1452

Audio Products

Audio D/A Converters

SigmaDSP Audio Processors

adau1962a

Show More

DIXOM.rar154.6 KB
MarcE Reply
Nov 9, 2018 00:00

Hello Alekssandr,
does your MCU reset the ADAU shortly before programming? (Pin 24). I remember i had similar problems which disappeared after inventing the reset.

Marc

ADIApproved Reply
Nov 9, 2018 00:00

HI Alekssandr:

In my experience this problems happen when there isn't enough time left for the PLL to settle although I see from your code that you indeed have a Delay inserted. IS this delay inserted @ the same place as SigmaStudio.

Also, sometimes to reproduce this problems we use the Sequencer Window built into SigmaStudio. Doing so allows users to test download sequences and therefore remove the uC to see if the problem is a DSP only problem OR a System related problem. Can we ask you to try that?

The problem we woulld face in trying to troubleshoot this problem is that we don't have hardware. In essence we would appreciate all the help you can provide in enabling us to reproduce the problem using ADI's evaluation boards and tools (SigmaStudio).

Lastly, one thing that comes to mind is, that there might be different clocks used for the codec as the ones use for the ADC/DAC. Would this be possible? I'll let other application engineers further comments with ideas to troubleshoot this problem.

Miguel

Alekssandr Reply
Nov 9, 2018 00:00

Problem solved!

It turns out the problem was in the DAC. But I did not understand why this all worked in the SELFBOOT mode, which led me astray.

I used the whole form of sending commands to the DAC using the generated SigmaStodio code. Out of despair, I took a datasheet on ADAU1962 and collected my own set of commands. In any case, Thank you all for responding!

DAC clocked from the output of the DSP clock, at a frequency of 12 288 kHz. Therefore, I think there should be no problems with synchronization.

Here is a set of commands to run ADAU1962 with my settings.

void Init_DAC_ADAU1962(){
////////TEAMS FOR STARTING DAC ADAU1962//////////
uint8_t PLL_CLK_CTRL0 [2] = {0x00,0x37}; //00 * 11 * 0 * 11 *0
uint8_t PLL_CLK_CTRL1 [2] = {0x01,0x33}; //00 * 11 * 0 * 0 * 1 * 1
uint8_t PDN_THRMSENS [2] = {0x02,0x20}; //00 * 1 * 0 * 0 * 0 * 0 * 0
uint8_t PAD_DRV [2] = {0x1C,0x10}; //0 * 0 * 3 * 0 * 0 * 0 * 0 * 0

I2C_2_Write((uint16_t) DEVICE_ADDR_DAC_ADAU1962, PLL_CLK_CTRL0, 2, 100);
I2C_2_Write((uint16_t) DEVICE_ADDR_DAC_ADAU1962, PLL_CLK_CTRL1, 2, 100);
I2C_2_Write((uint16_t) DEVICE_ADDR_DAC_ADAU1962, PDN_THRMSENS, 2, 100);
I2C_2_Write((uint16_t) DEVICE_ADDR_DAC_ADAU1962, PAD_DRV, 2, 100);
}

void DacMuteOFF(){
uint8_t DAC_CTRL0 [2] = {0x06,0x14}; //00 * 010 * 10 * 0
I2C_2_Write((uint16_t) DEVICE_ADDR_DAC_ADAU1962, DAC_CTRL0, 2, 100);
}

void DacMuteON(){
uint8_t DAC_CTRL0 [2] = {0x06,0x15}; //00 * 010 * 10 * 1
I2C_2_Write((uint16_t) DEVICE_ADDR_DAC_ADAU1962, DAC_CTRL0, 2, 100);
}

ADIApproved Reply
Nov 9, 2018 00:00