An nRF52840 audio board writes files labelled 16,000 samples per second. A ten-minute recording timed by an independent reference plays several seconds longer. Changing a healthy 32 MHz crystal to another of the same part makes little difference. Start with the microphone clock and the hardware decimation ratio. The file header describes the sample rate to a player and does not set the acquisition hardware.
Trace the three rates
Nordic describes the external 32 MHz quartz crystal as the reference for the high-frequency crystal oscillator. The PDM peripheral derives PDM_CLK from the high-frequency source. Microphone bits arrive at that clock rate and pass through hardware filtering and decimation to become PCM audio. The output sample rate is the PDM clock divided by the selected ratio. Identify each clock when recording the setup.
The default PDM clock is nominally 32 MHz divided by 31. With a decimation ratio of 64, that gives about 16,129.03 samples per second. The 1.28 MHz setting instead divides 32 MHz by 25. With a ratio of 80, that gives a nominal 16,000 samples per second. Read PDMCLKCTRL and RATIO together and check whether the wake or start routine changes either one.
Changing only the ratio can also produce an unintended rate. The default clock divided by 80 is about 12,903 samples per second. That arithmetic illustrates why the values belong together. For production, use a documented combination and verify the microphone's supported clock rate, duty cycle and data timing.
Compare actual sample count with elapsed time
At 16,129.03 samples per second, a continuous 600-second mono recording yields about 9,677,419 samples. Played at 16,000 per second, it lasts about 604.84 seconds. A 1 kHz tone in that recording plays at about 992 Hz. This example assumes no missing samples, no resampling and the correct channel count.
Use an independent time reference and two marker sounds separated by a known interval. Locate the same feature in each marker and compare the sample indices with the reference interval. Take filter delay and acoustic geometry into account. Common fixed delay cancels in a difference, while a changing delay needs investigation. Markers generated by the same clock as the device under test do not independently validate absolute recording time.
Capture PDM_CLK and a diagnostic signal that marks buffer service, then compare the calculated hardware rate with the number of samples actually saved. Nordic specifies alternating 16-bit left and right values for stereo in RAM. The sample-frame count sent to a stereo file differs from the total number of these 16-bit values. Verify channel count, byte count and the file header before diagnosing a scale or factor-of-two error.
When error occurs at a single point, sequence the buffers and record their frame counts. At 16,000 frames per second, a missing 320-frame buffer loses 20 ms at one position. A fixed sample-rate error accumulates across the recording. Document gaps whenever the device stops acquiring. After issuing STOP, wait for the documented STOPPED event before restarting with another configuration.
Decide whether the crystal needs requalification
Keep the selected clock source, PDM clock, decimation ratio, buffer sample count and recorded rate on the same test sheet. A repeatable ratio near the divider calculation points to a configuration or file-format check. A smaller sustained error after confirming the ratio calls for verifying the high-frequency source, startup and loading with an independent reference. A hypothetical 20 ppm rate error over 600 seconds is 12 ms, much smaller than the divider example.
Procurement should retain the full 32 MHz crystal order code, load, ESR, temperature range and data-sheet revision. Engineering should retain the microphone specification, approved clock and ratio combinations, and file format for each mode. Qualify new microphone or oscillator lots with the same test duration and marker signal. That gives both teams a practical basis for adjusting the clock, hardware configuration or file-handling path.
