cancel
Showing results for 
Search instead for 
Did you mean: 

Low signal from MP34DT05-A microphone on H743VIT6 with PDM2PCM library

Robmar
Senior III

The audio signal with 24dB gain set is reasonable quality but seems low in the noise.  I added a slew filter which helps a lot, but I expected a clearer audio above the noise.

The clock going to the mic chip is 1,024 MHz, these are my settings, if anyone has any ideas what might be causing this.  Clock and data signals look good, little ringing.

  /* SETUP USER CODE END I2S3_Init 1 */
  hi2s3.Instance = SPI3;
  hi2s3.Init.Mode = I2S_MODE_MASTER_RX;
  hi2s3.Init.Standard = I2S_STANDARD_PHILIPS;
  hi2s3.Init.DataFormat = I2S_DATAFORMAT_16B;
  hi2s3.Init.MCLKOutput = I2S_MCLKOUTPUT_DISABLE;
  hi2s3.Init.AudioFreq = I2S_AUDIOFREQ_32K;
  hi2s3.Init.CPOL = I2S_CPOL_LOW;
  hi2s3.Init.FirstBit = I2S_FIRSTBIT_MSB;
  hi2s3.Init.WSInversion = I2S_WS_INVERSION_DISABLE;
  hi2s3.Init.Data24BitAlignment = I2S_DATA_24BIT_ALIGNMENT_RIGHT;
  hi2s3.Init.MasterKeepIOState = I2S_MASTER_KEEP_IO_STATE_DISABLE;
  if (HAL_I2S_Init(&hi2s3) != HAL_OK)
END...

void MX_PDM2PCM_Init(void)
{
  /* USER CODE BEGIN 2 */
  /* USER CODE END 2 */

   /**
  */
	 __HAL_RCC_CRC_CLK_ENABLE();
	 CRC->CR = CRC_CR_RESET;

	volatile static bool bDo = 1;
	if (bDo)	// RT tester
	{
		PDM1_filter_handler.bit_order = PDM_FILTER_BIT_ORDER_MSB;
		PDM1_filter_handler.endianness = PDM_FILTER_ENDIANNESS_BE;	// PDM_FILTER_ENDIANNESS_LE
	}
	else
	{
		PDM1_filter_handler.bit_order = PDM_FILTER_BIT_ORDER_LSB;
		PDM1_filter_handler.endianness = PDM_FILTER_ENDIANNESS_LE;	// PDM_FILTER_ENDIANNESS_BE
	}
	PDM1_filter_handler.high_pass_tap = 1825361095;	//1932735282;	// 2104533974;	// 2122358088 / 2122358088
	PDM1_filter_handler.in_ptr_channels = 1;
	PDM1_filter_handler.out_ptr_channels = 1;
	uint32_t res = PDM_Filter_Init(&PDM1_filter_handler);
	assert(res == 0);

	PDM1_filter_config.decimation_factor = PDM_FILTER_DEC_FACTOR_128;
	PDM1_filter_config.output_samples_number = 4;
	PDM1_filter_config.mic_gain = 24;
	res = PDM_Filter_setConfig(&PDM1_filter_handler, &PDM1_filter_config);
	assert(res == 0);

  /* USER CODE BEGIN 3 */

CIRCULAR DMA IS TRANSFERING 32 HALF-WORDS TO MEMORY:-
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
{
#ifdef _DEBUG
#include "main.h"
	//HAL_GPIO_WritePin(DEBUG_SIGNAL_GPIO_Port, DEBUG_SIGNAL1_Pin, GPIO_PIN_RESET);
	HAL_GPIO_TogglePin(DEBUG_SIGNAL1_GPIO_Port, DEBUG_SIGNAL1_Pin);	// Toggle for scope
#endif

	static uint8_t uIX = 0;
volatile static bool bClear = 0;
	if (!bClear && PDM_Filter(pdmRxBuf, pcmBuffer, &PDM1_filter_handler) == 0)	// Get 8KHz mic sample
	{
               pcmBuffer IS 4 HALF WORDS, DATA ARRIVES.

 

1 REPLY 1
Robmar
Senior III

With the CubeMX setup following the examples for I2S with Philips protocol to a MIMC microphone, WS (LR) is setup so that it toggles with the clock phase, if this is connected to the MP34DT05A, it seems to generate signal noise.  I had thought that MXCube would have set it correctly, but disabling the GPIO code that it generated leaving WS floating high, seems to have reduced the level of noise.  Also the default gain of 24dB is way too high, 6dB gives a strong signal with less noise.

Again STM have very poor examples none of which mention the WS/LR signal line issue.
STM==Pain.