Is the I2S function of the STM32H7 series working normally?
I'm attempting to use I2S to drive the WM8978 for audio recording (the SAI pins are already occupied, so please don't suggest switching to SAI). I've ported the well-tested WM8978 driver code from the F4 series and configured I2S DMA to receive data. However, I haven't been able to receive audio data—there's only clean background noise. I've tested the waveforms at the I2S interface, and here's how I've configured I2S in my code:
<i2s config>
hi2s3.Instance = SPI3;
hi2s3.Init.Mode = I2S_MODE_MASTER_RX;
hi2s3.Init.Standard = I2S_STANDARD_PCM_SHORT;//I2S_STANDARD_PHILIPS;
hi2s3.Init.DataFormat = I2S_DATAFORMAT_16B;
hi2s3.Init.MCLKOutput = I2S_MCLKOUTPUT_ENABLE;
hi2s3.Init.AudioFreq = I2S_AUDIOFREQ_8K;
hi2s3.Init.CPOL = I2S_CPOL_LOW;
hi2s3.Init.FirstBit = I2S_FIRSTBIT_MSB;
hi2s3.Init.WSInversion = I2S_WS_INVERSION_DISABLE;
hi2s3.Init.Data24BitAlignment = I2S_DATA_24BIT_ALIGNMENT_RIGHT;
hi2s3.Init.MasterKeepIOState = I2S_MASTER_KEEP_IO_STATE_DISABLE;
<wm8978 config>
bsp_InitI2C();
wm8978_Init();
WM8978_ADDA_Cfg(0,1);
WM8978_Input_Cfg(1,0,0);
WM8978_Output_Cfg(0,1);
WM8978_MIC_Gain(46);
WM8978_LINEIN_Gain(5);
WM8978_I2S_Cfg(3,0);//PCM Format
MX_I2S3_Init();
<Callback>
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
{
if(hi2s->Instance == SPI3)
{
current_buf_flag = pcm_buf_flag;
pcm_buf_flag = !pcm_buf_flag;
HAL_I2S_Receive_DMA(&hi2s3, pcm_data[pcm_buf_flag], PCM_SIZE/2);
AsrEventFlag = true;
}
}
<main while>
while (1)
{
if(AsrEventFlag)
{
AsrEventFlag = false;
HAL_GPIO_TogglePin(GPIOE,GPIO_PIN_2);
HAL_UART_Transmit_IT(&huart5,(uint8_t*)pcm_data[current_buf_flag],PCM_SIZE);
}
}
The measured MCLK is 1.024 MHz, and WS, SCK, and SDI are all around 8 kHz, but I still can't receive audio data correctly. Why aren't there any I2S examples for the H7? Can someone who has used the H7's I2S interface help me out?
