运用NUCLEO-L476RG DFSDM接口 采集2个数字麦克风数据,Buf_Mic0和Buf_Mic1得到的数据基本都是0xFFFC,
调用 HAL_DFSDM_FilterRegularMsbStart_DMA(&hdfsdm1_filter0,Buf_Mic0,BUF_LENGTH);得到的数据是PCM数据吗?还是再需要软件解码为PCM?
以下代码,请大家帮忙看看,谢谢!
DFSDM_Filter_HandleTypeDef hdfsdm1_filter0;
DFSDM_Filter_HandleTypeDef hdfsdm1_filter1;
DFSDM_Channel_HandleTypeDef hdfsdm1_channel1;
DFSDM_Channel_HandleTypeDef hdfsdm1_channel2;
DMA_HandleTypeDef hdma_dfsdm1_flt0;
DMA_HandleTypeDef hdma_dfsdm1_flt1;
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
/* Private variables ———————————————————*/
#define SAMPLE_FREQ 8000
#define BYTE_PER_SAMPLE 2
#define MICROPHEN_NUMBER 2
#define FRAME_NUMBER 2
//16bit sample resolution
#define BUF_LENGTH (SAMPLE_FREQ/1000*MICROPHEN_NUMBER*FRAME_NUMBER)
/* Buffer 分配 */
int16_t Buf_Mic0[BUF_LENGTH];
int16_t Buf_Mic1[BUF_LENGTH];
int16_t test;
int16_t number;
/* USER CODE END PV */
/* Private function prototypes ———————————————–*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_DFSDM1_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes ———————————————–*/
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* 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();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_DFSDM1_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
HAL_DFSDM_FilterRegularMsbStart_DMA(&hdfsdm1_filter0,Buf_Mic0,BUF_LENGTH);
HAL_DFSDM_FilterRegularMsbStart_DMA(&hdfsdm1_filter1,Buf_Mic1,BUF_LENGTH);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
user151383853:
采集2个数字麦克风数据,Buf_Mic0和Buf_Mic1得到的数据基本都是0xFFFC,你是不是先示波器验证一下,麦克风的信号进去了么
user5142806:
回复 user151383853:
收到的0xFFFF和0x0000,这是PDM数据吧?需要添加官方解码库去解码吗?
Mickey Zhang:
DSP问题请在“数字信号处理器DSP ARM微处理器”。