cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H747I-DISCO-CM7 SAI audio interface DMA problem

BPraj.1
Associate II

Hello there,

I am trying to build a custom voice AI solution using STM32H747I-DISCO development kit, for which I generated the NN library code by importing a .tflite model via STM32CubeIDE and it works fine with a static Input buffer.

Now, I am trying to take the input from onboard MEMS MIC and (for the time being) just record the audio and play it to verify the recorded audio. For this, I referred to an example application named "BSP" provided under the board's firmware package. I copied the related audio BSP source files to my custom project and linked to the SAI peripheral drivers as in the example application. The project builds fine and I am able to run it on the M7 Core, but the application gets stuck in the function call "BSP_AUDIO_IN_RecordPDM()" and never returns. Whereas, on stepping inside the function while debugging, everything (DMA config, audio frequencies etc) looks fine and the function executes till the return statement with return value being 0 (as I verified in debug session variables).

I tried making the clock settings and hardware/peripheral initialization as same as the example code but got no luck in getting the audio recording running. I am stuck at this point where everything seems OK but still its not working, and have no idea how to debug it now. Please suggest me any workarounds or tweaks that I can try to understand where could I be making a mistake.

Pls Note: for now, I have removed calling the AI part, just keeping the audio record and play function in the main loop

As I am new to audio processing, any leads are highly appreciated.

Thanks and regards,

Bhupendra.

2 REPLIES 2
LCE
Principal

I just can give you some general advice on how I debug stuff like that - apart from using "real" debugging tools:

  • most simple: use some LEDs on / off at some points in the source code to check where it hangs
  • use some COM interface (uart) to change and check register settings - this is very important when using CubeMX and HAL stuff, because these are not always complete and / or correct, so compare registers to the reference manual

BPraj.1
Associate II

Hi @Community member​ ,

Sorry for the delayed reply and thank you for your suggestions,

It was my mistake actually, I forgot to add the SAI Audio In/out interrupt handler definitions to the stm32h7xx_it.c file, once I did it. The issue was resolved and I got into other issue of RAM_D3 access for which I had to edit the linker script ( ending with _FLASH.ld). This document came to a great help in identifying that https://community.st.com/s/article/FAQ-DMA-is-not-working-on-STM32H7-devices. Well I am still dealing with the issues on the audio recording side, may be some DCache and DMA problem, trying to resolve them.

Thanks for your kind support!

Regards,

Bhupendra