1

I am working on STM32F107 to read MP34DT05-A mems mic on I2S. I have tried any configuration setting with pdm2pcm.c and i2s.c but nothing shows the expected result.

The expected result is positive int value. This is what i did so far:

  • i2s3 (SPI3) set to master RX mode, standar msb, format 16b extended with audio freq 8k.

  • DMA2 channel 1 halfword, circular and very high priority.

  • PDM filter set to LSB, big endian, decimation by 64.

  • In main.c i'm calling it like this:

   usb_printf("\nMEAS MIC..");
   __HAL_RCC_CRC_CLK_ENABLE();
   HAL_I2S_Receive_DMA(&hi2s3, pdm_buff, 16);
   usb_printf("\nPDM BUFF: ");
   usb_printf(pdm_buff);
   while (1) {
         uint16_t *pcm_out;
         uint16_t *pdm_out;
         memcpy(cbuff, pdm_buff, sizeof(pdm_buff));
         PDM_Filter(&cbuff[0], &pcm_buff[0], &PDM1_filter_handler);
         usb_printf("pcm_buff: 0x%04X  ", pcm_buff[0]);
         usb_printf("pcm_buff int: %d", pcm_buff[0]);
   }
   delay_ms(500);

And the result is something like this:

 pcm_buff: 0xFFFF828F  pcm_buff int: -32113
 pcm_buff: 0xFFFFA2E3  pcm_buff int: -23837
 pcm_buff: 0xFFFFB379  pcm_buff int: -19591
 pcm_buff: 0xFFFFBFFF  pcm_buff int: -16385

Am I missing something? Or is there any missed configuration?

Pnzy
  • 25
  • 5
  • The types and declarations of all these variables is fundamental information, please post a [mcve]. – Lundin Apr 04 '22 at 08:14
  • @Lundin Thanks. edited. Am I missing something on my question? – Pnzy Apr 04 '22 at 15:38
  • You just removed even more code... we need more info, not less. It's not meaningful to view _any_ C code without knowing the types of all variables involved. Also you mention big endian, is there a conversion from little to big somewhere? – Lundin Apr 04 '22 at 16:31

0 Answers0