cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4P5 SAI2-A no signal output issue

SaB0tAgE
Associate II

Dear all,

I hope I can receive som help from you. I'm struggling since a couple of days with SAI2 block A on the mentionned MCU.

I am using STM32CubeIDE and I have configured it using HAL library in master mode with MCLK output.

When I try to send some data I don't see nothing on the scope on ANY pin. I have checked all related registers, RCC, GPIO and also the alternate function.

So, I have tried to configure it using LL drivers and directly set SAI2 register:

static void peripheral_sai2_init(void)
{
	LL_GPIO_InitTypeDef GPIO_InitStruct =
	{ 0 };
 
	/* Configure PLLSAI1 clock Input: HSE 16MHz - Output: 10.666 MHz */
	LL_RCC_PLLSAI1_ConfigDomain_SAI(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLSAI1M_DIV_6, 28, LL_RCC_PLLSAI1P_DIV_7);
	LL_RCC_PLLSAI1_EnableDomain_SAI();
	LL_RCC_PLLSAI1_Enable();
 
	/* Wait PLLSAI1 becomes ready */
	while(LL_RCC_PLLSAI1_IsReady() != 1)
	{
 
	}
 
	/* Select clock source for SAI2 interface */
	LL_RCC_SetSAIClockSource(LL_RCC_SAI2_CLKSOURCE_PLLSAI1);
 
	/* Enable SAI2 peripheral clock */
	LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SAI2);
 
	/* SAI2 GPIO setup */
 
	/**SAI2_A_Block_A GPIO Configuration
	 PB12     ------> SAI2_FS_A
	 PB13     ------> SAI2_SCK_A
	 PB14     ------> SAI2_MCLK_A
	 PB15     ------> SAI2_SD_A
	 */
	GPIO_InitStruct.Pin = LL_GPIO_PIN_12 | LL_GPIO_PIN_13 | LL_GPIO_PIN_14 | LL_GPIO_PIN_15;
	GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
	GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
	GPIO_InitStruct.Speed = LL_GPIO_SPEED_LOW;
	GPIO_InitStruct.Alternate = LL_GPIO_AF_13;
	LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
 
	/* OSR256:0 | NOMCK:0 | DMA:0 | STEREO | CKSTR:0 | DS: 7 (32bit) | MASTER TX: 0 */
	SAI2_Block_A->CR1 = 0x2E0;
	SAI2_Block_A->CR2 = 0;
	/* FSOFF: 1 | FSPOL:0 | FSDEF: 1 | FSALL: 31 | FRL: 63*/
	SAI2_Block_A->FRCR = 0x51F3F;
	/* SLOTEN: 0xFFFF | NBSLOT: 1 | SLOTSZ: 2 (32bit) | FBOFF: 0 */
	SAI2_Block_A->SLOTR = 0xFFFF0180;
	SAI2_Block_A->IMR = 0;
	SAI2_Block_A->CLRFR = 0;
 
	/* Enable SAI2 */
	SAI2_Block_A->CR1 |= 1 << 16;
}

I only see that the LS signal stays High meaning a sort of configuration but when I try to drop some data on the DR register, still nothing happen!

SAI2_Block_A->DR = 0xDEADBEEF;

I see that the FIFO buffer becomes full.

Do I forgot something ? Is there something else to set on RCC ? PLL ? Whatever else ? Neither on silicon errata sheet is written someting about it!

Thank you in advance for your precious help!

5 REPLIES 5

> have checked all related registers, RCC, GPIO and also the alternate function.

Post their content.

JW

SaB0tAgE
Associate II

I found what's not correct!

There's a bug on SAI clock source selection. The impacted function is this: 

LL_RCC_SetSAIClockSource(LL_RCC_SAI2_CLKSOURCE_PLLSAI1);

 ... even if argument is PLLSAI1 as source, it selects another value.

Looking at RCC register it has a value that does not correspond to the value specified on reference manual for PLLSAI1! It selects in that case PLLSAI2

0693W000007Bq4oQAC.png 

Is there a way to report this bug ?

Nice catch!

And maybe this is a good indicator of what's the value of unnecessary intermediary "libraries"...

Hi @Imen GH​ ​ ,

I still don't know who is the proper person to report these things to, so can you please forward this to the proper Cube/LL group. Thanks.

Jan

​Hello @Community member​,

I take your feedback into consideration.

Thank you.

Imen

Thanks, Imen!

Jan

@Imen GH​