In order to convert the incoming data stream into PCM audio samples, a decimation filter is included in the PDM interface module.
The input of the filter is the two-channel PDM serial stream (with left channel on clock high, right channel on clock low). Its output is 2 × 16-bit PCM samples at a sample rate lower than the PDM clock rate at a ratio depending on the RATIO register.
The filter stage of each channel is followed by a digital volume control, to attenuate or amplify the output samples in a range of -20 dB to +20 dB around the default (reset) setting, defined by GPDM,default. The gain is controlled by the GAINL and GAINR registers.
- Sum the PDM module's default gain (GPDM,default) and the gain introduced by the microphone and acoustic path of his implementation (an attenuation would translate into a negative gain)
- Adjust GAINL and GAINR by the above summed amount. Assuming that only the PDM module influences the gain, GAINL and GAINR must be set to -GPDM,default dB to achieve the requirement.
With GPDM,default = 3.2 dB, and as GAINL and GAINR are expressed in 0.5 dB steps, the closest value to program would be 3.0 dB, which can be calculated as:
GAINL = GAINR = (DefaultGain - (2 * 3))
Remember to check that the resulting values programmed into GAINL and GAINR fall within MinGain and MaxGain.