程序无法退出中断功能
我正在尝试从板上的MEMS麦克风(STM32F746G)中检索声音。我正在尝试使用BSP库。我的董事会具有WM8994音频编解码器,其示意图为在这里。
我编写了下面显示的代码:
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stm32746g_discovery_audio.h"
#include "wm8994.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
#define AUDIO_BLOCK_SIZE ((uint32_t)0xFFFE)
#define AUDIO_NB_BLOCKS ((uint32_t)4)
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
I2C_HandleTypeDef hi2c3;
SAI_HandleTypeDef hsai_BlockA2;
SAI_HandleTypeDef hsai_BlockB2;
DMA_HandleTypeDef hdma_sai2_b;
DMA_HandleTypeDef hdma_sai2_a;
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void PeriphCommonClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_SAI2_Init(void);
static void MX_I2C3_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
void BSP_AUDIO_IN_TransferComplete_CallBack(void);
void BSP_AUDIO_IN_HalfTransfer_CallBack(void);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint32_t audio_rec_buffer_state;
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
uint8_t res = 0;
uint16_t internal_buffer[AUDIO_BLOCK_SIZE];
uint32_t bytesread = 0;
/* USER CODE END 1 */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Configure the peripherals common clocks */
PeriphCommonClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_SAI2_Init();
MX_I2C3_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
audio_rec_buffer_state = BUFFER_OFFSET_NONE;
res = BSP_AUDIO_IN_Init(INPUT_DEVICE_DIGITAL_MICROPHONE_2, 35, AUDIO_FREQUENCY_44K);
if(!res) {
res = BSP_AUDIO_IN_Record(internal_buffer, AUDIO_BLOCK_SIZE);
for (int block_number = 0; block_number < AUDIO_NB_BLOCKS; ++block_number) {
while(audio_rec_buffer_state != BUFFER_OFFSET_HALF);
audio_rec_buffer_state = BUFFER_OFFSET_NONE;
while(audio_rec_buffer_state != BUFFER_OFFSET_FULL);
audio_rec_buffer_state = BUFFER_OFFSET_NONE;
}
BSP_AUDIO_IN_Stop(CODEC_PDWN_SW);
BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE, 35, AUDIO_FREQUENCY_44K);
BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02);
res = BSP_AUDIO_OUT_Play(internal_buffer, AUDIO_BLOCK_SIZE);
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
// Callback Functions
void BSP_AUDIO_IN_TransferComplete_CallBack(void)
{
audio_rec_buffer_state = BUFFER_OFFSET_FULL;
return;
}
void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
{
audio_rec_buffer_state = BUFFER_OFFSET_HALF;
return;
}
这里的问题是,当我执行调试时,程序将进入IRQ功能,并且无法从那里退出。该功能如下:
void DMA2_Stream7_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream7_IRQn 0 */
/* USER CODE END DMA2_Stream7_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_sai2_b);
/* USER CODE BEGIN DMA2_Stream7_IRQn 1 */
/* USER CODE END DMA2_Stream7_IRQn 1 */
}
有什么问题?我希望一切都清楚。我是STM32的新手,所以如果我忘记了什么,我感到非常抱歉。感谢您提前回复。 注意:我实际上想在Cubemx中添加SAI外围设备配置的照片,但是我需要添加很多链接,因此我的问题是垃圾邮件。因此,我不得不删除它们。
I am trying to retrieve sound from MEMS microphones of my board, STM32F746G-Discovery. I am trying to use BSP Library. My board has wm8994 audio codec, and its schematic is here.
I wrote a code which appears below:
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "stm32746g_discovery_audio.h"
#include "wm8994.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
#define AUDIO_BLOCK_SIZE ((uint32_t)0xFFFE)
#define AUDIO_NB_BLOCKS ((uint32_t)4)
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
I2C_HandleTypeDef hi2c3;
SAI_HandleTypeDef hsai_BlockA2;
SAI_HandleTypeDef hsai_BlockB2;
DMA_HandleTypeDef hdma_sai2_b;
DMA_HandleTypeDef hdma_sai2_a;
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
void PeriphCommonClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_SAI2_Init(void);
static void MX_I2C3_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
void BSP_AUDIO_IN_TransferComplete_CallBack(void);
void BSP_AUDIO_IN_HalfTransfer_CallBack(void);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
uint32_t audio_rec_buffer_state;
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
uint8_t res = 0;
uint16_t internal_buffer[AUDIO_BLOCK_SIZE];
uint32_t bytesread = 0;
/* USER CODE END 1 */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* Configure the peripherals common clocks */
PeriphCommonClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_SAI2_Init();
MX_I2C3_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
audio_rec_buffer_state = BUFFER_OFFSET_NONE;
res = BSP_AUDIO_IN_Init(INPUT_DEVICE_DIGITAL_MICROPHONE_2, 35, AUDIO_FREQUENCY_44K);
if(!res) {
res = BSP_AUDIO_IN_Record(internal_buffer, AUDIO_BLOCK_SIZE);
for (int block_number = 0; block_number < AUDIO_NB_BLOCKS; ++block_number) {
while(audio_rec_buffer_state != BUFFER_OFFSET_HALF);
audio_rec_buffer_state = BUFFER_OFFSET_NONE;
while(audio_rec_buffer_state != BUFFER_OFFSET_FULL);
audio_rec_buffer_state = BUFFER_OFFSET_NONE;
}
BSP_AUDIO_IN_Stop(CODEC_PDWN_SW);
BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_HEADPHONE, 35, AUDIO_FREQUENCY_44K);
BSP_AUDIO_OUT_SetAudioFrameSlot(CODEC_AUDIOFRAME_SLOT_02);
res = BSP_AUDIO_OUT_Play(internal_buffer, AUDIO_BLOCK_SIZE);
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
// Callback Functions
void BSP_AUDIO_IN_TransferComplete_CallBack(void)
{
audio_rec_buffer_state = BUFFER_OFFSET_FULL;
return;
}
void BSP_AUDIO_IN_HalfTransfer_CallBack(void)
{
audio_rec_buffer_state = BUFFER_OFFSET_HALF;
return;
}
The problem here is that when I perform debugging, the program enters an IRQ function, and cannot exit from there. The function is below:
void DMA2_Stream7_IRQHandler(void)
{
/* USER CODE BEGIN DMA2_Stream7_IRQn 0 */
/* USER CODE END DMA2_Stream7_IRQn 0 */
HAL_DMA_IRQHandler(&hdma_sai2_b);
/* USER CODE BEGIN DMA2_Stream7_IRQn 1 */
/* USER CODE END DMA2_Stream7_IRQn 1 */
}
What's the problem? I hope everything is clear. I am very new to stm32 so I am very sorry if I forget something. Thank you for your response in advance.
Note: I actually wanted to add photos of configuration of SAI peripherals in CubeMX, but I needed to add a lot of links so stackoverflow though my question as spam. I therefore had to remove them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论