cancel
Showing results for 
Search instead for 
Did you mean: 

DMA is not working with SAI

rubenles
Associate III

hi,

I am using stm32h743zit6.

I am having problems with DMA in my code. First i have a code that is not mine that takes data from a peripheral (a microphone) using SAI and then via DMA inserts this data into an array (a buffer). To do this memory is modified to do this.

I am doing the same configuration in other code to try to do this, in the original one the data refreshes automatically and in my own code, it just takes the first read.

 

ALIGN_32BYTES (int32_t __attribute__((section (".dmapart"))) dmaArray[data]);
HAL_SAI_Receive_DMA(&hsai_BlockA3,(uint8_t)* dmaArray, (uint16_t) data);

 

All the GPIO is ok because i just copied the same code. SCB_EnableIcache() is written in the main..., I don't know why is not  updating the data in my array and is working well in the other code. Anyone have any idea why is not updating in my code?

If any of you need more info about the code tell me please. 

 

Thank you so much, i am desperating.

13 REPLIES 13

Found, i will answer you if i have any success, thank you so much @KDJEM.1 

The solution is to fix a line in the hal libraries because the code was deleting the configuration on CR  about double buffer. 

KDJEM.1
ST Employee

Hello @rubenles ,

Thank you for updating post and glad to know that you find the solution.

Could you please give more detail about the solution this may help the community members who facing the same issue:

Which line in HAL did you fix? And how?

Thank you.

Kaouthar

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.

in stm32h7xx_hal_dma.c

Line 1800 aprox

  if(IS_DMA_STREAM_INSTANCE(hdma->Instance) != 0U) /* DMA1 or DMA2 instance */
  {
    /* Clear all interrupt flags at correct offset within the register */
    regs_dma->IFCR = 0x3FUL << (hdma->StreamIndex & 0x1FU);

    /* Clear DBM bit */
    //((DMA_Stream_TypeDef *)hdma->Instance)->CR &= (uint32_t)(~DMA_SxCR_DBM);<-----

Last line delete CR using double buffer