cancel
Showing results for 
Search instead for 
Did you mean: 

SAI(audio interface) issue on STM32F7 MCU

Edwin kaus
Associate II
Posted on November 25, 2017 at 13:06

Hi.,

I am working on STM32F7 evolution board(Nucleo-F767ZI ) to interface external audio kit through SAI interface , I configured and got SAI drivers with STM cubeMX , The STM board is configured in Master mode with one block as transmitter and another as receiver(one block is working synchronously with another block ) and enabled the DMA to receive & transmit.

I can able to transmit data through SAI interface , but problem is with receiving . I am getting data for the first time through DMA , then onwards no data is receiving , same time I checked signals on board(FS,SCK & SD) all are coming but data is not receiving in to buffer. If I call SAI_DMAAbort() and then call receive function again data is receiving. What could be the problem. Should I need to abort DMA all the time or what.

SAI configurations:

  hsai_BlockA1.Instance = SAI1_Block_A;

  hsai_BlockA1.Init.AudioMode = SAI_MODEMASTER_TX;

  hsai_BlockA1.Init.Synchro = SAI_ASYNCHRONOUS;

  hsai_BlockA1.Init.OutputDrive = SAI_OUTPUTDRIVE_ENABLE;

  hsai_BlockA1.Init.NoDivider = SAI_MASTERDIVIDER_ENABLE;

  hsai_BlockA1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF;

  hsai_BlockA1.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_48K;

  hsai_BlockA1.Init.SynchroExt = SAI_SYNCEXT_DISABLE;

  hsai_BlockA1.Init.MonoStereoMode = SAI_STEREOMODE;

  hsai_BlockA1.Init.CompandingMode = SAI_NOCOMPANDING;

  hsai_BlockA1.Init.TriState = SAI_OUTPUT_NOTRELEASED;

  if (HAL_SAI_InitProtocol(&hsai_BlockA1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK)

  {

    _Error_Handler(__FILE__, __LINE__);

  }

  hsai_BlockB1.Instance = SAI1_Block_B;

  hsai_BlockB1.Init.AudioMode = SAI_MODESLAVE_RX;

  hsai_BlockB1.Init.Synchro = SAI_SYNCHRONOUS;

  hsai_BlockB1.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;

  hsai_BlockB1.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF;

  hsai_BlockB1.Init.SynchroExt = SAI_SYNCEXT_DISABLE;

  hsai_BlockB1.Init.MonoStereoMode = SAI_STEREOMODE;

  hsai_BlockB1.Init.CompandingMode = SAI_NOCOMPANDING;

  hsai_BlockB1.Init.TriState = SAI_OUTPUT_NOTRELEASED;

  if (HAL_SAI_InitProtocol(&hsai_BlockB1, SAI_I2S_STANDARD, SAI_PROTOCOL_DATASIZE_24BIT, 2) != HAL_OK)

  {

    _Error_Handler(__FILE__, __LINE__);

  }

I have attached function calling detail documents for reference.

#nucleo-f767zi #stm32f7
6 REPLIES 6
Nesrine M_O
Lead II
Posted on November 27, 2017 at 14:18

Hi

karthikshivanna.94

,

Have you try to start from SAI example under the STM32F7cube firmware package:

STM32Cube_FW_F7_V1.8.0\Projects\STM32756G_EVAL\Examples\SAI

-Nesrine-

Posted on November 28, 2017 at 05:19

Hai.,

I have taken same example project as reference , But I am getting lot of issues , 

>> I am not able continuously receive data through DMA(I need to call DMA abort every time before calling receive DMA function).

>> Also DMA receive call function effecting other global data buffers that I have defined.

I have attached part of initialization , Transmit & receive function calls in last thread , Can you please cross check and suggest if anything I am doing wrong.

Thank you.,

Donald Bosley
Associate II
Posted on December 07, 2017 at 03:24

Did you set DMA up to circular buffer?

Posted on December 07, 2017 at 05:24

Hi Donald.,

No I haven't set DMA in circular mode , I chosen as normal mode. 

Posted on December 08, 2017 at 20:49

If you want it to continuously transmit, you should use a circular buffer - otherwise you will have to tell the SAI every time you want to Rx data. You'll probably want to also use a 'ping-pong' or double-buffer scheme with your receiving location in memory by setting the half complete, and complete interrupts.

Posted on December 09, 2017 at 05:51

Hi Donald .,

Do you mean If I set in circular buffer no need to call receive function again and again . Once I call receive function then does it automatically all frames coming from SAI.

OK now I got some clarity to proceed further , If I suppose to set 8K bytes DMA receive mode , when half complete interrupt arrives then we can take first 4K buffer data and then so on.

Also I need some clarity what is maximum size I can set to DMA receive buffer. As per my above assumption will it support 8Kbytes size.

Thank you