2025-11-10 10:56 PM
STM32WBA54 SAI work in slave mode with DMA: SAI1_Block_A Slave out, SAI1_Block_B Slave in.
test code as:
MX_SAI1_Init();
//in
static HAL_StatusTypeDef SAI_Disable(SAI_HandleTypeDef *hsai)
{
uint32_t count = SAI_DEFAULT_TIMEOUT * (SystemCoreClock / 7U / 1000U);
HAL_StatusTypeDef status = HAL_OK;
/* Disable the SAI instance */
__HAL_SAI_DISABLE(hsai);
do
{
/* Check for the Timeout */
if (count == 0U)
{
/* Update error code */
hsai->ErrorCode |= HAL_SAI_ERROR_TIMEOUT;
status = HAL_TIMEOUT;
break;
}
count--;
} while ((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != 0U);
return status;
}
Solved! Go to Solution.
2025-11-13 1:09 AM
Hi,
I understand the situation, and I see a workaround that could apply for some specific use case:
If the BCLK line is in high Z due to the missing master (or master configuration), it is possible to get out of this situation (pending transfers) by generating few edges on the BLCK, for example with a loop for enabling the GPIO pull up, then pull down few times while the GPIO still in alternate function (GPIOx_PUPDR)
2025-11-12 6:21 AM
Hello Huang,
I can reproduce the issue and have the same conclusion. I read from the reference manual that "SAIEN bit remains high until the SAI is completely switched off at the end of the current audio frame transfer", so probably without the BCLK we never end the current audio frame transfer, I am waiting the confirmation of this behavior (internal ID 221613)
Did you tried to reconfigure the SAI after performing an IP reset from the RCC ? (APB2RSTR / SAI1RST).
Best regards,
2025-11-12 10:01 PM
Hi TMANE,
Set APB2RSTR / SAI1RST could reset the SAI successfully.
But this settings will cause both SAI1_Block_A and SAI1_Block_B reset simultaneously, if I want to just stop audio out(SAI1_Block_A ) and keep audio in(SAI1_Block_B), I have to re-initialize audio in(SAI1_Block_B) and lost some audio in data.
2025-11-13 1:09 AM
Hi,
I understand the situation, and I see a workaround that could apply for some specific use case:
If the BCLK line is in high Z due to the missing master (or master configuration), it is possible to get out of this situation (pending transfers) by generating few edges on the BLCK, for example with a loop for enabling the GPIO pull up, then pull down few times while the GPIO still in alternate function (GPIOx_PUPDR)