0

I am working on a PCM3060 driver and will share some of the initialization I am doing here. So this narrated post can help others looking on the internet perhaps. Before getting to code, I do not have any input or output circuit. I am just listening/scoping the output wires but I see noise. I do see it waking up when STM32 initiates transfer.

initialization code:

H

AL_GPIO_WritePin(CODEC_RST_GPIO_Port, CODEC_RST_Pin, GPIO_PIN_SET);

// MRST
uint16_t ret = HAL_I2C_Mem_Read(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
data &= \~(REG_MRST);
ret = HAL_I2C_Mem_Write(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
HAL_Delay(4);

// SRST
ret =HAL_I2C_Mem_Read(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
data &= \~(REG_SRST);
ret =HAL_I2C_Mem_Write(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
HAL_Delay(4);

// powersave
ret = HAL_I2C_Mem_Read(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
data &= \~(REG_ADPSV);
ret = HAL_I2C_Mem_Write(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
HAL_Delay(4);
ret = HAL_I2C_Mem_Read(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
data &= \~(REG_DAPSV);
ret = HAL_I2C_Mem_Write(&hi2c1, codec_address, REG_SYS_CTRL, 1, &data, 1, 250);
HAL_Delay(4);

// alignment i2s std
uint8_t adc_ctrl, dac_ctrl = 0;
HAL_I2C_Mem_Read(&hi2c1, codec_address, REG_ADC_FMT1, 1, &adc_ctrl, 1, 250);
adc_ctrl |= 0x00;
HAL_I2C_Mem_Write(&hi2c1, codec_address, REG_ADC_FMT1, 1, &adc_ctrl, 1, 250);
HAL_Delay(4);

HAL_I2C_Mem_Read(&hi2c1, codec_address, REG_DAC_FMT1, 1, &dac_ctrl, 1, 250);
dac_ctrl |= 0x00;
HAL_I2C_Mem_Write(&hi2c1, codec_address, REG_DAC_FMT1, 1, &dac_ctrl, 1, 250);
HAL_Delay(4);

HAL_GPIO_WritePin(CODEC_RST_GPIO_Port, CODEC_RST_Pin, GPIO_PIN_SET);

HAL_TIM_Base_Start_IT(&htim2);

timer callback:

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef* htim)
{
    ret_t = HAL_I2S_Transmit(&hi2s2, lut, 256, 50);
}

direct output of VL+ VR+ combined https://i.stack.imgur.com/uXQpA.jpg

I tried various ways to initialize, skip initialization, etc. Monitoring the lines with a logic analyzer, I couldn't see data passing except for MCK.

Emir
  • 1
  • It's not very clear (to me) which bit doesn't work. Does the I2C interface seem to be ok? Can you read sensible values from the chip? Can you remove the timer and just have a loop sending data? Have you probed the I2S bus to see if it has clock and data? What is `lut`? – pmacfarlane Apr 06 '23 at 21:42

0 Answers0