Forum Rule: Always post complete source code & details to reproduce any issue!

# Thread: Sampling 44.1kHz

1. ## Sampling 44.1kHz

Hi.

Out of curiosity, I am just wondering how to sample data at 44.1kHz. I know the history behind CD with 44.1kHz sampling rate. But how they do it with a timer interrupt ?
I have been sampling data with interval timer at 25microseconds which equivalent to 40ksps. But I am confused on how to sample data at 44.1kHz. Should I just pass 22.6757 microseconds interval timer (which is not round number) ?? If the interrupt is at 20microsecs, it would become 50ksps instead. Hope Paul or other experts see this :)

Many thanks and have a great day !
xx

2. The exact samplerate T3.x uses is 44117.xyz Hz. T4 uses 44100 exactly.

3. Originally Posted by scarlet_bear
But how they do it with a timer interrupt ?
You could do it as Paul does it with usb_audio.
There every ms is an usb-interrupt. So usb_audio sends 9 x 44 samples and 1 x 45 samples resulting in 44.1 samples/ms on average. There is a phase jitter you have to live with.

4. Frank is right, on Teensy 3.x we use a frequency close but not exactly 44.1 kHz.

When the PDB timer is the clock master, it's generated from 48 MHz / 1088, or 60 MHz / 1360, because the timers default to running at 48 MHz on Teensy 3.2 and 60 MHz on Teensy 3.5 and 3.6. The timers only allow dividing these base clock frequencies by an integer, so we use integers 1088 and 1360 to get the closest possible frequency and hope that's close enough.

When the I2S MCLK generator is the clock master, similar integer ratios of 96 MHz or 120 MHz or 180 MHz are used.

On Teensy 4.0, we have a dedicated PLL which allows creating a very accurate 44.1 kHz sample rate.

5. Thank you Frank, Walter and Paul for clear explanation.

Cheers :)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•