Skip to main content
akoluacik
Associate III
June 17, 2022
Question

How to Use BSP Library for Audio Recording?

  • June 17, 2022
  • 4 replies
  • 2663 views

I'd like to create a program by which I can record and listen sound by using my board, STM32F746G-Disco. I'd like to use BSP library, however, I have some questions.

When I looked at the stm32746g_discovery_audio.c file, I saw that there are 2 global variables named haudio_out_sai and haudio_in_sai, and there are some functions that configures these sai components. Then do I need to enable and configure SAI components in CubeMX. Because in the documentation of the library, it is said that the functions configure the related components about the audio, but these functions don't take any SAI parameters.

This topic has been closed for replies.

4 replies

KnarfB
Super User
June 19, 2022

For audio recording from the MEMS mics, you just use BSP_AUDIO_IN_Init and BSP_AUDIO_IN_Record.

pass a buffer (global variable) to the Record function and implement two callbacks BSP_AUDIO_IN_HalfTransfer_CallBack and void BSP_AUDIO_IN_TransferComplete_CallBack(void) that grab the audio samples and do wa´hatever you need to do with it.

BSP_AUDIO_IN_InitEx sjhall be able to get line-in audio, not tested.

hth

KnarfB

akoluacik
akoluacikAuthor
Associate III
June 20, 2022

KnarB, thank you for your answer.

However, the problem is that, my program goes into DMA2_Stream7_IRQHandler

function when it executes BSP_AUDIO_IN_Record, and cannot terminate the function, in other words, it cannot exit from that function.

I also ask the issue in stackoverflow, can be accessed by this link.

KnarfB
Super User
June 20, 2022

Here is a complete project: https://gitlab.com/KnarfB/stm32f746g-disco.git

My IRQ handler at the end of stm32f7xx_it.c:

/* USER CODE BEGIN 1 */
#include "stm32746g_discovery_audio.h"
 
extern SAI_HandleTypeDef haudio_in_sai;
 
void AUDIO_IN_SAIx_DMAx_IRQHandler(void)
{
	HAL_DMA_IRQHandler(haudio_in_sai.hdmarx);
}
/* USER CODE END 1 */

The implementations of HAL_SAI_RxHalfCpltCallback and HAL_SAI_RxCpltCallback in stm32746g_discovery_audio.c call the BSP_AUDIUO_IN_* callbacks straight ahead.

Don't understnad what you mean by "stm32746g_discovery_audio.c"/" it cannot exit" because you implement those functions and can return at any time.

Note that there is a chip bug that may trap the debugger in some timer interrupt. This only happend when yo step through the code.

hth

KnarfB