54.6.2.6 Gain and Offset Compensation
An offset, a gain, a scaling factor and a shift can be applied to a converted PDM microphone value using the following operation:
where:
- data0 is a signed integer defined on 24 bits. It is the output of the filtering channel.
- offset is a signed integer defined on 16 bits (see PDMIC DSP Configuration Register 1). It is multiplied by 28 to have the same weight as data0.
- dgain is an unsigned integer defined on 15 bits (see PDMIC DSP Configuration Register 1). Only the 32 MSBs of the multiplication operation are used for scaling and shifting operations. dgain defaults to 0 after reset, which forces CDR to 0. It must be programmed to a non-zero value to read non-zero data into the PDMIC_CDR register.
- scale is an unsigned integer defined on 4 bits (see PDMIC DSP Configuration Register 0). It shifts the multiplication operation result by scale bits to the right. Maximum allowed value is 15.
- shift is an unsigned integer defined on 4 bits (see PDMIC DSP Configuration Register 0). It shifts the multiplication operation result by shift bits to the right. Maximum allowed value is 15.
If the data transfer is configured in 32-bit mode (see PDMIC DSP Configuration Register 0), the 2shift division is not performed and the 32-bit result of the remaining operation is sent.
If the data transfer is configured in 16-bit mode, the 2shift division is performed. The result is then saturated to be within ±(215-1) and the 16 LSBs of this saturation operation are sent to the controller as the result of the PDM microphone conversion.
Default parameters are defined to output a 16-bit result whatever the data transfer configuration may be.