AnsweredAssumed Answered

PCM sound to PC -> Stm32f4 microphone

Question asked by Bati_.Klemen on Apr 11, 2017
Latest reply on Apr 11, 2017 by Nesrine M

Hello!

I am using "STM32Cube_FW_F4_V1.14.0\Projects\STM32F4-Discovery\Examples\BSP" modified example for recording audio. 

As far as I understand the audio is recorded, converted from PDM to PCM and saved into WrBuffer. Data is uint16_t. I am sending it with function HAL_UART_Transmit, which sends 8 bit data.

"HAL_UART_Transmit(&huart6, (uint8_t *)  WrBuffer, WR_BUFFER_SIZE*2, 5000);"

I send it after the function  AudioRecord_Test(); function call.

 

On my PC I use matlab to receive data and to cast it to 16 bit. Code for casting:

a =uint8(fread(s)); %reads the data from the serial port and stores it to the matrix a
res = (typecast(uint8(a), 'uint16'));

 

When recording sound: sine vawe , snap of fingers, etc... The plotted data does not have a recognisable pattern, it looks like noise, althoug I can hear the sound clearly on playback via STM board.

 

I am quite sure the conversion in Matlab works, because I tryed sending uint16_t sine vawe (lookup table) via uart and the matlab reconstructed it perfectly

 

So what am I doing wrong? I added some photos of MIC sound. I hope I provided enough info, if not I´ll be glad to.

Thanks for help!

Attachments

Outcomes