cancel
Showing results for 
Search instead for 
Did you mean: 

What is the HAL configuration on the STM34F4 discovery for playing wav files converted to 16b hex through the CS43L22 vis I2S?

TNixo
Associate

I'm trying to get the discovery board to play a wav file that I've converted to an array of 16b hex values. So far, I have only been able to output an obnoxious noise.

I have tried keeping the registered in the CS43L22 all at default.

I have tried configuring the beep to ensure that the uC is talking properly but the beep isn't working either.

Does anyone have any experience getting this working with the new HAL libs and where I might have gone wrong?

Sample command to enable the CS43L22. Do I have the address and data in the right order for the HAL_I2C_Master_Transmit function?

  audioControl [0] = 0x02;
  audioControl [1] = 0x9E;
  if(HAL_I2C_Master_Transmit(&hi2c1,0x94,audioControl,2,50) != HAL_OK)
  {
	  HAL_GPIO_WritePin(GPIOD, LD5_Pin, GPIO_PIN_SET);
  }

I2C Config

  hi2c1.Instance = I2C1;
  hi2c1.Init.ClockSpeed = 100000;
  hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  hi2c1.Init.OwnAddress1 = 0;
  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c1.Init.OwnAddress2 = 0;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  {
    _Error_Handler(__FILE__, __LINE__);
  }

I2S Config

 hi2s3.Instance = SPI3;
 
 hi2s3.Init.Mode = I2S_MODE_MASTER_TX;
 
 hi2s3.Init.Standard = I2S_STANDARD_MSB;
 
 hi2s3.Init.DataFormat = I2S_DATAFORMAT_16B;
 
 hi2s3.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE;
 
 hi2s3.Init.AudioFreq = I2S_AUDIOFREQ_44K;
 
 hi2s3.Init.CPOL = I2S_CPOL_LOW;
 
 hi2s3.Init.ClockSource = I2S_CLOCK_PLL;
 
 hi2s3.Init.FullDuplexMode = I2S_FULLDUPLEXMODE_DISABLE;
 
 if (HAL_I2S_Init(&hi2s3) != HAL_OK)
 
 {
 
  _Error_Handler(__FILE__, __LINE__);
 
 }

0 REPLIES 0