Module operation

nRF54LM20A | nRF54LM20B Datasheet

By default, bits from the left PDM microphone are sampled on PDM_CLK falling edge, and bits for the right are sampled on the rising edge of PDM_CLK, resulting in two bitstreams. Each bitstream is fed into a digital filter which converts the PDM stream into 16-bit PCM samples, then filters and down-samples them to reach the appropriate sample rate.

The EDGE field in the MODE register allows swapping left and right channels, so that left will be sampled on rising edge, and right on falling.

The PDM module uses EasyDMA to store the samples coming out from the filters into one buffer in RAM. Depending on the mode chosen in the OPERATION field in the MODE register, memory either contains alternating left and right 16-bit samples (Stereo), or only a left (or only right, depending on the value of the EDGE field) 16-bit samples (Mono). To ensure continuous PDM sampling, it is up to the application to update the EasyDMA destination address pointer as the previous buffer is filled.

The continuous transfer can be started or stopped by sending the START and STOP tasks. STOP becomes effective after the current frame has finished transferring, which will generate the STOPPED event. The STOPPED event indicates that all activity in the module is finished, and that the data is available in RAM (EasyDMA has finished transferring as well). Attempting to restart before receiving the STOPPED event may result in unpredictable behavior.

Soft Gain/Mute

A short description of the Gain, Mute, and Soft Gain/Mute functionality is provided below.

Gain

The gain is configurable in the range [-20, 20] dB, using the following registers:
  • GAINL – left channel, in 0.5 dB steps
  • GAINR – right channel, in 0.5 dB steps
  • FILTER.CTRL.GAINADD0P25 – additional gain, one optional +0.25 dB step that applies to both channels

Custom oversampling rates and CIC filter gain compensation

PDM supports gain compensation, for the selected decimation/oversamling ratio (OSR).

The decimation ratio is set in RATIO, as either one of the listed ratios, or the special value Custom. When RATIO=Custom, the actual decimation rate is configured using the register FILTER.CTRL.DECRATIO. When using custom decimation ratios, configure register FILTER.CTRL.CICFILTERMSBCUSTOM to match FILTER.CTRL.DECRATIO.

PDM uses partial gain compensation towards the closest upper power of 2. For the fixed OSR ratios, compensation gain is fixed and pre-calculated in the design. However, when using custom oversampling ratios, the gain compensation must be calculated and configured.

To calculate the additional compensated gain for Custom OSR ratios, please follow the steps below:
  1. Calculate the CIC filter gain:

    gainCIC = OSR5

    where OSR is the oversampling ratio and the CIC filter order is 5.

  2. Determine the closest upper power of 2:

    closePow2 = floor(log2(gainCIC)) + 1

  3. Calculate the required gain compensation:

    gainComp = -20 × log10(gainCIC / 2closePow2) dB

  4. Configure the compensation registers:
    Note: These registers are only active when RATIO = Custom (Custom decimation ratio mode).

Mute

The Mute function is a specific case of the Gain function, where the gain coefficient is set to 0.

This function is controlled using the FILTER.SOFTMUTE register.

Soft Gain/Mute

The Soft Gain/Mute provides the possibility to gradually change the gain setting, to avoid a sudden gain change which may lead to audible clicks.

The Soft Gain/Mute function is controlled using the registers FILTER.SOFTCYCLES (the number of soft cycles at the baseband frequency). If FILTER.SOFTCYCLES is set to Custom, then the actual number of softcycles used is configured using the register FILTER.CTRL.SOFTCYCLES (using a multiplication factor of 32).

Gain Range

The desired gain range is [-20, 20]dB with 0.5 dB steps, with the option to improve gain resolution to 0.25 dB steps.