Skip to main content
Graduate
October 27, 2023
Question

STM32H747 - I2S Fullduplex with DMA is not working

  • October 27, 2023
  • 5 replies
  • 4654 views

I'm trying to build an audio project using STM32H747 MCU.

I wish to configure the cortex M7 to process the audio in and out buffers.

I'm trying to work with double buffers of input and output. the DMA should handle the transactions to and from the i2s peripheral.

 

HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t*)&outBuffer[0][0], (uint16_t*)&inBuffer[0][0], AUDIO_BUFFER_U16_STREAMS/4);

 

and the half & full complete callbacks are:

void HAL_I2SEx_TxRxHalfCpltCallback (I2S_HandleTypeDef *hi2s) {

pInBuffer = &inBuffer[0][0];

pOutBuffer = &outBuffer[0][0];

// SCB_CleanDCache();

// SCB_InvalidateDCache();

dataReadyFlag = true;

}

 

void HAL_I2SEx_TxRxCpltCallback (I2S_HandleTypeDef *hi2s) {

pInBuffer = &inBuffer[1][0];

pOutBuffer = &outBuffer[1][0];

// SCB_CleanDCache();

// SCB_InvalidateDCache();

dataReadyFlag = true;

}

 

and all I'm doing in the super loop is to copy the input to the output when I have dataReadyFlag == true.

 

I hooked all the I2S lines to a data logger and the peripheral seems to work.

but whenever I get a new buffer from DMA it is Empty and all set to '0'.

 

Why this is happening ?

please help me with e full explanation on how to fix this.

as you can see I already tried setting the buffer to a specific RAM location to prevent DMA and Catch issues but it didn't help. maybe I did it wrong.

 

    This topic has been closed for replies.

    5 replies

    Super User
    October 27, 2023

    A few things to consider:

    Graduate
    October 27, 2023

    OK so just to be clear,

    the catch is disabled
    my code is attached
    here is what I've added to the Flash.ld file:

     

    .ram2Block (NOLOAD) :

    {

    KEEP (*(.MY_RAM_D2))

    } > RAM_D2

    then I defined the buffers:

    __attribute__ (( section(".MY_RAM_D2") )) uint16_t inBuffer[2][AUDIO_BUFFER_SIZE_U16_ARRAY] = {0};

    __attribute__ (( section(".MY_RAM_D2") )) uint16_t outBuffer[2][AUDIO_BUFFER_SIZE_U16_ARRAY] = {0};

    __attribute__ (( section(".MY_RAM_D2") )) volatile uint16_t* pInBuffer = &inBuffer[1][0];

    __attribute__ (( section(".MY_RAM_D2") )) volatile uint16_t* pOutBuffer = &outBuffer[1][0];

     

    still not working

    Graduate
    October 30, 2023

    I request ST's employe's help, and exact explenation and instructions on what to do to make the STM32H747 work with fullduplex I2S and DMA stream, i.e: HAL_I2Sex_TransmitRecieveDMA.

     

    It's ST's FLAGSHIP MCU and it's simpely not working out of the box.

    Super User
    October 30, 2023

    i have it working, on H743 (almost same cpu, but only H7 core) . and it was working "out of the box". in 16bit data mode.

    just in 32bit mode it didnt work with my dac, so i use SAI , the "better" I2S connection.

     

    btw i use circular buffers, 4096 x int16  size .

    Super User
    October 30, 2023

    Note that this is primarily a user run forum, not a direct link to ST support.

    You can initiate an online support request here:

    https://www.st.com/content/st_com/en/support/support-home.html

    Graduate II
    October 31, 2023

    I'm using I2S / SAI DMA on H723 and H735 in DBM mode, running smoothly for hours.

    Show your DMA setup.

    Often, it is the DMA's width setting. For a start, use half-word (16bit) or word (32bit) in both directions.

    And I think I had to modify the HAL DMA start function in DBM mode.

    Graduate II
    November 21, 2023

    Better reply than edit your first post.

    Anyway... so you are not using DBM mode, with double buffer you mean you are using 2 buffers?

    Here:

    HAL_I2SEx_TransmitReceive_DMA(&hi2s2, (uint16_t*)&outBuffer[0][0], (uint16_t*)&inBuffer[0][0], AUDIO_BUFFER_U16_STREAMS/4);

    DMA always reads & writes to xBuffer[0], it will never ever use xBuffer[1], but in the complete callback pointers are set to xBuffer[1].

    You should start with RX buffer all the same values (something recognisable like 0xA5A5, but neither 0 nor 0xFFFF),
    then fill your TX buffer with e.g. "i++".
    Then, as a start, leave out any other hardware and directly connect I2S data in and out.

    For debugging, don't copy anything, just check your RX buffer, which should be equal to TX buffer.

    Super User
    November 21, 2023

    I believe it was moved by Amel, which triggers the notification. Don't think the OP has been back since the original couple replies.