2022-06-17 04:16 AM
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.
2022-06-19 01:24 PM
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
2022-06-20 01:05 AM
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.
2022-06-20 09:58 AM
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
2022-06-20 10:58 AM
stm32f746g_discovery.c part isn't important now. The important thing is that I think I cannot clear the interrupt, or somehow my code cannot terminate the interrupt. My problem is this. I am saying this because I cannot exit IRQHandler function.
BTW, this code is taken from official example. I am already using same code.
tfyh. If you have any more suggestion, I am very pleased.