 the digital filter parameters.
Another advantage of using dfsdm rather than sampler is that analog components can be removed from the circuit design, thereby reducing the risk of interference from radio transceivers such as WiFi and Bluetooth.
The imp004m’s dfsdm behaves very much like the sampler object, both in terms of how it is configured and how it operates. The dfsdm object is set up using the dfsdm.configure() method, which takes as parameters the desired digital filter settings, and an array of blobs as buffers. Each time a buffer is filled with data, a buffer-processing callback function is executed and passed the filled buffer. This callback is registered using dfsdm.configure(). Optionally, the buffers can be pre-processed with a selection of audio processing filters.
While the sampler provides 16-bit samples, dfsdm is capable of producing samples of up to 24 bits in depth. Without any pre-processors specified, dfsdm will provide buffers of 24-bit unsigned samples in the least significant bits of Squirrel 32-bit signed integers. An additional pre-processor is provided to convert these 24-bit samples into 16-bit samples, two of which are packed into each 32-bit word.
The digital filter has three configurable parameters: the filter order, the decimation rate and the integration rate.
The filter order can be interpreted as the number of levels of feedback provided, where a single level of feedback comprises a 1-bit DAC that feeds the sampled delta back to the original analog signal. Different filter orders result in different frequency response characteristics of the resulting output. The quantization noise arising from the conversion is arranged to be present in a different part of the spectrum than the signal of interest. It is through this technique, sometimes known as ‘noise shaping’, that the approach employed by DFSDM can achieve a much better signal to noise ratio than a traditional ADC, especially as bit depth is increased.
The decimation rate is the number of times the signal is oversampled. The higher the decimation rate, the lower the effective sample rate for a given resolution (bit depth).
The integration rate is the number of times the output is oversampled. The effective sample rate and resolution are affected by the integration rate in the same manner as the decimation rate: higher integration rates will decrease the sample rate, but increase the resolution.
To determine the effective output sample rate, the frequency of the clock is divided by the product of the decimation and integration rates:
For example, if a 48kHz output sample rate (fo) is required, a clock of 3,072,000Hz could be driven to the CLK input pin (fCLK), and the filter could be configured with a decimation rate (dOSR) of 32 and an integration rate (iOSR) of 2.
Since CLK is not configured by the API, and may be coming from an external source, the sample rate cannot be determined prior to commencing operation. However, once at least one sample has been collected, the effective sample rate can be retrieved via dfsdm.getsampleratehz().
Three additional parameters are provided in the API when configuring dfsdm: the DC offset correction applied to the sample, the clock edge (rising or falling) on which the bit stream is sampled through DATA, and the number of bits by which the resulting sample is shifted right in the output.
When using DFSDM without any of the optional audio processing filters, the signed samples are provided in the least significant 24 bits of a 32-bit word. The effective bit-depth of these samples is determined by the filter parameters passed to dfsdm.configure() by the following relationship:
Where Afs denotes the maximum value that can be sampled by DFSDM, dOSR is the decimation rate, fORD is the filter order and iOSR is the integration rate.
For example, if we choose a fORD = 4, we get a fourth-order filter. The maximum value that can be sampled is calculated by raising the decimation rate dOSR to the power of the filter order, then multiplying by the integration rate iOSR. Let’s say we choose decimation rate 64