cancel
Showing results for 
Search instead for 
Did you mean: 

STM32MP157F-DK2 SAI Receive FIFO Not Filling. Block A configured as MasterTX, Block B configured as SlaveRX.

ASnow.1
Associate II

SAI2 Block A configured as a MasterTX and works. Fs configured for 48KHz, bit clock configured as 64*Fs and MCLK as 256*MCLK. I've verified these signals are sent to the audio codec which is configured as a slave (receives MCLK, SCLK, LRCLK (Fs)). The audio codec provides a transmit line and receive line for data. I'm successful with my asynchronous block A in sending audio to the audio codec but when I configure block B as synchronous to block A, the FIFO never fills, and I've verified this inside the HAL_SAI_Receive function. It just times out. I've verified that the audio data is on the SDB line as well via an oscilloscope.

Might be related, but on the development boards GPIO connector which exposes all SAI2 pins except MCLK, all signals read as 0v even though reading off of the audio codecs lines, I get the correct signals that I'm generating on those lines. Just an extra problem. I don't have this issue with the I2C that I connect to the audio codec with.

Heres the configuration of the SAI:

//Error Check Variable
	HAL_StatusTypeDef SAI_Check_A;
	HAL_StatusTypeDef SAI_Check_B;
	
	//Populate Init struct with I2S properties
	hsaib->Instance 				= SAI2_Block_B;
	hsaib->Init.AudioMode			= SAI_MODESLAVE_RX;
	hsaib->Init.Synchro 			= SAI_SYNCHRONOUS; 
	hsaib->Init.SynchroExt			= SAI_SYNCEXT_DISABLE;
	hsaib->Init.MckOutput			= SAI_MCK_OUTPUT_ENABLE;
	hsaib->Init.OutputDrive			= SAI_OUTPUTDRIVE_DISABLE; 
	hsaib->Init.NoDivider			= SAI_MASTERDIVIDER_ENABLE;
	hsaib->Init.FIFOThreshold		= SAI_FIFOTHRESHOLD_FULL; 
	hsaib->Init.AudioFrequency		= SAI_AUDIO_FREQUENCY_48K;
	hsaib->Init.Mckdiv				= 2;
	hsaib->Init.MckOverSampling		= SAI_MCK_OVERSAMPLING_DISABLE;
	hsaib->Init.MonoStereoMode		= SAI_MONOMODE;
	hsaib->Init.CompandingMode		= SAI_NOCOMPANDING;
	hsaib->Init.TriState			= SAI_OUTPUT_NOTRELEASED;
 
	
	//Populate Init struct with I2S properties
	hsaia->Instance					= SAI2_Block_A;
	hsaia->Init.AudioMode			= SAI_MODEMASTER_TX;
	hsaia->Init.Synchro 			= SAI_ASYNCHRONOUS; 
	hsaia->Init.SynchroExt			= SAI_SYNCEXT_DISABLE; 
	hsaia->Init.MckOutput			= SAI_MCK_OUTPUT_ENABLE;
	hsaia->Init.OutputDrive			= SAI_OUTPUTDRIVE_DISABLE; 
	hsaia->Init.NoDivider			= SAI_MASTERDIVIDER_ENABLE;
	hsaia->Init.FIFOThreshold		= SAI_FIFOTHRESHOLD_EMPTY; 
	hsaia->Init.AudioFrequency		= SAI_AUDIO_FREQUENCY_48K;
	hsaia->Init.Mckdiv				= 2;
	hsaia->Init.MckOverSampling		= SAI_MCK_OVERSAMPLING_DISABLE;
	hsaia->Init.MonoStereoMode		= SAI_MONOMODE;
	hsaia->Init.CompandingMode		= SAI_NOCOMPANDING;
	hsaia->Init.TriState			= SAI_OUTPUT_NOTRELEASED;
	
	
	//Initialize SAI with I2S protocol
	SAI_Check_B = HAL_SAI_InitProtocol(	hsaib, 
										SAI_I2S_STANDARD,
										SAI_PROTOCOL_DATASIZE_24BIT, 
										2
									);
 
	
	//Initialize SAI with I2S protocol
	SAI_Check_A = HAL_SAI_InitProtocol(	hsaia, 
										SAI_I2S_STANDARD,
										SAI_PROTOCOL_DATASIZE_24BIT, 
										2
									);
 
 
	if (SAI_Check_A == HAL_ERROR)
	{
		print_string("SAIA ERROR\n", 11);
	}
	
	if (SAI_Check_B == HAL_ERROR)
	{
		print_string("SAIB ERROR\n", 11);
	}

and here is my GPIO config for the SAI:

GPIO_InitTypeDef GPIO_InitStruct;
	
	//PE0 - MCLKA
	GPIO_InitStruct.Pin			= GPIO_PIN_0;
	GPIO_InitStruct.Mode		= GPIO_MODE_AF_PP;
	GPIO_InitStruct.Pull		= GPIO_NOPULL;
	GPIO_InitStruct.Speed		= GPIO_SPEED_FREQ_VERY_HIGH;
	GPIO_InitStruct.Alternate	= GPIO_AF10_SAI2;
	
	HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
	
	//PI5, PI6, PI7 - SCKA, SDA, FSA
	GPIO_InitStruct.Pin			= GPIO_PIN_5 | GPIO_PIN_7 | GPIO_PIN_6;
	GPIO_InitStruct.Mode		= GPIO_MODE_AF_PP;
	GPIO_InitStruct.Pull		= GPIO_NOPULL;
	GPIO_InitStruct.Speed		= GPIO_SPEED_FREQ_VERY_HIGH;
	GPIO_InitStruct.Alternate	= GPIO_AF10_SAI2;
	
	
	HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
	
	//PF11 - SDB
	GPIO_InitStruct.Pin			= GPIO_PIN_11;
	GPIO_InitStruct.Mode		= GPIO_MODE_AF;
	GPIO_InitStruct.Pull		= GPIO_NOPULL;
	GPIO_InitStruct.Speed		= GPIO_SPEED_FREQ_VERY_HIGH;
	GPIO_InitStruct.Alternate	= GPIO_AF10_SAI2;
	
	HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

The GPIO clocks are enabled for the various ports I use as well as the SAI2 clock. I feed the SAI2 module with PLL3_Q which runs at ~24.5MHz. Audio codec is configured for I2S standard as well. I've tried various synchronizing combinations as well to no success. I appreciate any help with this.

1 REPLY 1
Kevin HUBER
ST Employee

Hello @ASnow.1​ ,

I have seen that you already got support on reddit about the same question:

https://www.reddit.com/r/embedded/comments/sr6gjd/stm32mp1_sai_module_slave_rx_fifo_not_filling_tx/

I add the link to the post here because a lot of information were provided and can help other users.

Thank you @DGree.2​  for your great help on this case!

I am not an SAI expert, but do you still need help on this issue?

Regards,

Kevin

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.