Part Number Hot Search : 
30T110 PN918 ISL58831 1N5302 C3216X5R HGDFPA QA0505XS B8279
Product Description
Full Text Search
 

To Download AN3998 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  october 2011 doc id 022391 rev 1 1/10 AN3998 application note pdm audio software decoding on stm32 microcontrollers 1 introduction this application note presents the algorithms and architecture of an optimized software implementation for pdm signal decoding and au dio signal reconstruction when connecting an st mp45dt02 mems microphone with an stm32 microcontroller. it can directly take the pulse density modulated (pdm) data output from the microphone and convert it to 16-bit pulse-code modulation (pcm) format. this document also provides quick start information describing how to implement the pdm library for single microphone acquisition via i2s based on the stm32f4 microcontroller and stm32f4discovery board. for more details about this implementation, please refer to an3997 audio playback and recording using the stm32f4discovery . www.st.com
contents AN3998 2/10 doc id 022391 rev 1 contents 1 introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 pdm signal introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3 hardware interface: mi crophone connection and acquisit ion . . . . . . . 5 4 software interface: digital signal processing . . . . . . . . . . . . . . . . . . . . . 6 4.1 pdm digital filtering and decimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.2 digital signal conditioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 5 pdm audio software decoding libr ary description . . . . . . . . . . . . . . . . . 7 5.1 pdm_filter_init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 5.2 pdm_filter_xx_xx . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
AN3998 list of figures doc id 022391 rev 1 3/10 list of figures figure 1. block diagram of a microphone connection to an stm32. . . . . . . . . . . . . . . . . . . . . . . . . . . 5 figure 2. digital signal processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
pdm signal introduction AN3998 4/10 doc id 022391 rev 1 2 pdm signal introduction pulse density modulation, or pdm, is a form of modulation used to represent an analog signal in the digital domain. in a pdm signal, specific amplitude values are not encoded into pulses as they would be in pcm. instead it is the relative density of th e pulses that corresponds to the analog signal's amplitude. to get the framed data from the pdm bit stream, decimation filters are usually used. the first stage of decimation is used to reduce the sampling frequency, followed by a high pass filter to remove the signal dc offset.
AN3998 hardware interface: microphone connection and acquisition doc id 022391 rev 1 5/10 3 hardware interface: microphone connection and acquisition the mp45dt02 mems microphone outputs a pdm signal, which is a high frequency (1 to 3.25 mhz) stream of 1-bit digital samples. this output is acquired in blocks of 8 samples by using a synchronous serial port (spi or i2s) of the stm32 microcontroller. the microphone's pdm output is synchronous with its input clock; therefore an stm32 spi/ i2s peripheral generates a clock signal for the microphone. figure 1. block diagram of a microphone connection to an stm32. ms19892v1 internal flash i2s pdm lib microphone mems usb key stm32 i2s clk to mic clk mic data to i2s sd
software interface: digital signal processing AN3998 6/10 doc id 022391 rev 1 4 software interface: digital signal processing the data coming from the microphone is sent to the decimation process, which consists of two parts: a decimation filter converting 1-bit pdm data to pcm data, followed by two individually configurable iir filters (low pass and high pass). the reconstructed audio is in 16-bit pulse-code modulation (pcm) format. after the conversion, it produces raw data that can be handled depending on the application implementation (stored as wave/compressed data in a mass storage media, transferred to an external audio codec dac through i2s peripheral...). figure 2. digital signal processing 4.1 pdm digital filtering and decimation the pdm signal from the microphone is filtered and decimated in order to obtain a sound signal at the required frequency and resolution. the frequency of the pdm data output from the microphone (which is the clock input to the microphone) must be a multiple of the final audio output needed from the system. for example, to perform a decimation of 80, for the output rate of 30 khz, we need to provide a clock frequency 2.4mhz to the microphone. the output of the filter pipeline is a 16-bit value, we consider [-32768, 32767] as the output range for a unitary gain (0 db). 4.2 digital signal conditioning the digital audio signal resulting from the previous filter pipeline is further processed for proper signal conditioning. the first stage is a high pass filter designed mainly to remove the signal dc offset. it has been implemented via an iir filter with a cut-off frequency below the audible frequency range in order to preserve signal quality. the second stage is a low pass filter implemented using an iir filter. both filters can be enabled/disabled and configured (cut-off frequencies) by using the filter initialization function.gain can be controlled by an external integer variable (micgain) as shown in the following equation: g = micgain/64. ms19893v1 pdm digital filtering and decimation digital signal conditioning pdm in audio out
AN3998 pdm audio software decoding library description doc id 022391 rev 1 7/10 5 pdm audio software decoding library description the pdm library is composed of a structure and the implementation of four pdm filter functions. the library uses two buffers, the pdm input buffer and the pcm output buffer; the application must define these buffers in the main program. input buffer (data) is a uint8 variable with a length equal to (output frequency / 1000 * decimation factor * input microphone channels / 8) at least. output buffer (dataout) is a uint16 variable with a length equal to (output frequency / 1000 * output microphone channels) at least. the structure is defined in the pdm_filter.h file and is used to configure the filter; it is composed as follows: typedef struct { uint16_t fs; float lp_hz; float hp_hz; uint16_t out_micchannels; char internalfilter[34]; } pdmfilter_initstruct; fs: defines the frequency output of the filter in hz. lp_hz: defines the low pass filter cut-off frequency. if 0, the low pass filter is disabled. hp_hz: defines the high pass filter cut frequency. if 0, the high pass filter is disabled. in_micchannels: define the number of microphones in the input stream. this parameter is used to specify the interlacin g of microphones in the input buffer. the pdm samples are grouped eight by eight in u8 format (8-bit). out_micchannels: defines the number of microphones in the output stream; this parameter is used to interlace different microphones in the output buffer. each sample is a 16-bit value. internalfilter: defines a 34 byte memory used internally by the library during the pdm decimation step. the pdm audio software decoding library includes one header file pdm_filter.h and binary/object codes for the following platforms: libpdmfilter_iar.a : for iar compiler libpdmfilter_keil.lib : for arm compiler libpdmfilter_gcc.a : for gnu compiler this library is provided in the "stm32f4-discovery board firmware package" (v1.10 and later) under the following path 'utilities\stm32f4-discovery' 5.1 pdm_filter_init this function is used to initia lize the filter of a single output channel. it is defined as follows: void pdm_filter_init (pdmfilter_initstruct * filter)
pdm audio software decoding library description AN3998 8/10 doc id 022391 rev 1 it initializes the pdm filter, accordin g to the parameters specified in the pdmfilter_initstruct. the following is an example of filter initialization for a single microphone with a pdm at 16 khz: pdmfilter_initstruct filter; filter.lp_hz = 8000; filter.hp_hz = 10; filter.fs = 16000; filter.out_micchannels = 1; filter.in_micchannels = 1; pdm_filter_init ((pdmfilter_initstruct *) filter); before calling the pdm_f ilter_init() functi on, the application code mu st enable the clock of the stm32 microcontroller crc peripheral (configurati on done in rcc register). otherwise, the pdm_filter_init() function will fail and go into an infinite loop. 5.2 pdm_filter_xx_xx these functions are used to process a millisecond of pd m data from a single microphone. they return a number of pcm samples equal to the frequency defined in the filter initialization, divided by 1000. in case of frequencies that are not multiple of 1000 (like 44100 hz or 22050 hz), the samples returned by the function are equal to the floor division of the frequencies (44 and 22). the functions are defined as follows: pdm_filter_xx_xx(uint8_t* data, uint16_t* dataout, uint16_t micgain, pdmfilter_initstruct * filter) data: is the input buffer containing the pdm; the application must pass to the function the pointer to the first input sample of the microphone that must be processed. dataout: is the output buffer processed by the pdm_filter function. the application must pass to the function the pointer to the first sample of the channel to be obtained. volume: is a value between 0 and 64 used to specify the microphone gain. filter: is the structure containing all the filter parameters specified by the user using the pdm_filter_init function. there are four different implementations of this function depending on the decimation factor (64 or 80) and on the lsb or msb representation of the input buffer.
AN3998 revision history doc id 022391 rev 1 9/10 6 revision history table 1. document revision history date revision changes 27-oct-2011 1 initial release.
AN3998 10/10 doc id 022391 rev 1 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by two authorized st representatives, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2011 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - philippines - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN3998

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X