cancel
Showing results for 
Search instead for 
Did you mean: 

problem with PDM_TO_PCM converting on STM324xG_EVAL board

rizzo
Associate II
Posted on July 05, 2015 at 07:33

I want to use  ST MEMS microphone (MP45DT02) on STM324xG_EVAL board, I used an extension board and attached the digital microphone to the board. It works very well with 

Audio_playback_and_record

 code, but I have to increase size of InternalBuffer (INTERNAL_BUFF_SIZE) because I have some problems whit fast calling the BSP_AUDIO_IN_HalfTransfer_CallBack andBSP_AUDIO_IN_TransferComplete_CallBack.

The value of INTERNAL_BUFF_SIZE in code has been defined as:                  

#define INTERNAL_BUFF_SIZE             128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR

When I try to increase this value, I encounter serious problems in PDM_FilterXX_XX (inBSP_AUDIO_IN_PDMToPCM function).

My questions:

1-

      1-

Can I increase the value of INTERNAL_BUFF_SIZE? Which value should I use?

2-

      2-

Dose PDM_FilterXX_XX ‘s input and output (uint8_t* data, uint16_t* dataOut) have predefined and constant size or I can increase them?
  • When I increase it, the quality of voice drop and it becom really unclear.

4 REPLIES 4
Posted on July 05, 2015 at 15:24

If you ported code from the DISCO board, be aware it uses an 8 MHz HSE crystal, and the EVAL board uses an 25 MHz one. Check PLL settings, and HSE_VALUE to ensure clock based arithmetic is correct.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rizzo
Associate II
Posted on July 06, 2015 at 09:23

Dear clive1

Thanks for your quick answer

I‘ve configured it, my code is working very well with default value for

INTERNAL_BUFF_SIZE

.

But I need to increase the

size of InternalBuffer (INTERNAL_BUFF_SIZE) and  when I try to increase the value of INTERNAL_BUFF_SIZE the quality of voice drops.

Actually I want to getting data from microphone (and converting it to PCM) last more time because I want to do something else in that time.how can I do it? please help me.

rizzo
Associate II
Posted on July 06, 2015 at 11:46

Dear clivel

Thanks for your attention, I want to explain my problem in detail:

Actually the problem is not arises from fimware porting, audio firmware is already working well in stm32fg evaluation as well as stm32f discovery.

In my project I have merged http server  with uSD and digital microphones code.I want to record a voice as a wave file on uSD and download it from a remote computer as http client.

Everthing is working well in my merged program except one thing.When I want to download a file via http server while MCU is recording a digital voice into uSD the operation is failed,with debugging tools I found that the function ''PDM_Filter_64_LSB'' is the source of the problem,when I comment it,the problem is removed.

The thing which I found is that this function takes a long time for execution and as it is placed in ISR it destroy the timing requirements for uSD related functions like (f_open,f_read,...) and so the operation of application (http download via uSD) has been failed accordingly.

To avoid this problem I put ''disable,enable interrupt instruction'' before and after f_open and f_read functions to remove the problem and it works and my problem removed but it causes another problem!! Now some voice data is missed,because the size of the pdm buffer is not as large as needed and so during f_read or f_open operation we missed lots of audio packets as we disabled interrupt.

To solve this problem I've started to increase the size of the pdm buffer,but It doesnt work,because I couldn't increase the size of the pdm_filter as well.(in input parameters of PDM_Filter_64_LSB function thee is no way to show buffer size).

And now I dont know how to solve the problem.

I will appreciate for your advice.

Best Regards

PS:Please let me know if you have Telegram account,so I can call u for better communication

chrif
Associate II
Posted on July 06, 2015 at 12:52

Hi Adriana,

Under the application Note AN3998, you have some details on how buffers are used in page 7.

 

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/DM00040808.pdf?s_searchtype=keyword

And instead of increasing the buffer size, you can call many times the function PDM_Filter_64_LSB

Also, There is an example under STM32F4-Discovery/Applications/Audio/Audio_playback_and_record. In the readme.txt, it is mentioned that :

''To avoid data corruption:

 

- DMA ISR priority must be set at a Lower priority than USB interrupt sources,

 

  this priority order must be respected when managing other interrupts;

 

- The processing time of converting/filtering samples from PDM to PCM

 

  PDM_Filter_64_LSB()) should be lower than the time required to fill a

 

  single buffer.''

 

 

I hope this can help you.

Regards