Skip to main content
Graduate II
October 2, 2025
Question

STM32H747I-DISCO SAI onboard Microphone DMA error

  • October 2, 2025
  • 2 replies
  • 323 views

Post edited by ST moderator to be inline with the community rules especially with the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code

HI 

I am having an issue with starting measurements using the on-board microphone. Everything has been configured based on the BSP code, but set up from scratch using CubeMX. The problem is that when I start the DMA Receive

 

if (HAL_SAI_Receive_DMA(&hsai_BlockA4, (uint8_t*)PDM_Buffer, PDM_BUF_SIZE) != HAL_OK)

{

printf("SAI RX start error!\r\n");

}

else

{

printf("SAI RX started OK");

}

//callbacks:

void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai)

{

printf("HAL_SAI_RxHalfCpltCallback\n");

}



void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)

{

printf("HAL_SAI_RxCpltCallback\n");

}



void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)

{

printf("SAI error: 0x%08lx\n", hsai->ErrorCode);

}

 

I immediately get an interrupt reporting a DMA error (128 eror code in decimal).

I have already tried changing the clock frequencies, tried running it on a different core, and also tested with different data sizes, but none of this helped.

My config below: 

Patryk_Kucia_0-1759444319767.png

Patryk_Kucia_7-1759444919056.png

 

 

Patryk_Kucia_1-1759444362651.png

Patryk_Kucia_2-1759444374961.png

Patryk_Kucia_3-1759444681177.png

Patryk_Kucia_4-1759444688360.png

Patryk_Kucia_5-1759444697031.png

Patryk_Kucia_6-1759444716121.png

 

 

 

 

 

    This topic has been closed for replies.

    2 replies

    Technical Moderator
    October 3, 2025

    Hello @Patryk_Kucia 


    @Patryk_Kucia wrote:

    I immediately get an interrupt reporting a DMA error (128 eror code in decimal).


    Please could you specify which flag that generate this?

     

    Graduate II
    October 3, 2025

    HI 
    IDK if it's what you meant but i did it like this :

    	void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
    	{
    		printf("SAI error: 0x%08lx\n", hsai->ErrorCode);
    		 if (hsai->ErrorCode & HAL_SAI_ERROR_OVR) printf(" -> Overrun error\n");
    		 if (hsai->ErrorCode & HAL_SAI_ERROR_UDR) printf(" -> Underrun error\n");
    		 if (hsai->ErrorCode & HAL_SAI_ERROR_DMA) printf(" -> DMA transfer error\n");
    		 if (hsai->ErrorCode & HAL_SAI_ERROR_TIMEOUT) printf(" -> Timeout error\n");
    	}

    and got:

    -> DMA transfer error

    so i went deeper:

     if (hsai->ErrorCode & HAL_SAI_ERROR_DMA)
    		 {
    		 if (hsai->hdmarx != NULL)
    		 printf(" -> DMA RX error: 0x%08lx\n", hsai->hdmarx->ErrorCode);
    		 if (hsai->hdmatx != NULL)
    		 printf(" -> DMA TX error: 0x%08lx\n", hsai->hdmatx->ErrorCode);
    		 }

     and interestingly enough I got:

    DMA TX error: 0x00000001

    #define HAL_DMA_ERROR_TE (0x00000001U) /*!< Transfer error */

    but why is there a sending error if I only want to save?

    Technical Moderator
    October 3, 2025

    Hello @Patryk_Kucia 

    Could you please share your dma config?

    Graduate II
    October 3, 2025

    Patryk_Kucia_1-1759535424746.png

    and simply 

     if (HAL_SAI_Receive_DMA(&hsai_BlockA4, (uint8_t*)PDM_Buffer, PDM_BUF_SIZE) != HAL_OK)
     {
     printf("SAI RX start error!\r\n");
     }
     else
     {
     printf("SAI RX started OK\n");
     }