adafruit / Adafruit_ZeroI2S

I2S audio playback library for the Arduino Zero / Adafruit Feather M0 (SAMD21 processor).
MIT License
34 stars 16 forks source link

48kHz output mismatch #13

Open 23justJohn19 opened 1 year ago

23justJohn19 commented 1 year ago

Hi!

I2S audio amplifier connected to the standard pins (D0 frame clock, D1 bit clock, D9 data). Works well and is stable with all the Adafruit Github demos included in the library, thanks so much for sharing this code.

My specific issue is in the DMA demo from here:

https://github.com/adafruit/Adafruit_ZeroI2S/blob/master/examples/dma/dma.ino

This demo code works perfectly and I've verified the frame sync frequency on my 'scope is correct:

  /* begin I2S on the default pins. 24 bit depth at
   * 44100 samples per second
   */
  i2s.begin(I2S_32_BIT, 44100);
  i2s.enableTx();

  stat = myDMA.startJob();

However, changing the sample rate to this instead

  /* begin I2S on the default pins. 24 bit depth at
   * 44100 samples per second
   */
  i2s.begin(I2S_32_BIT, 48000);
  i2s.enableTx();

  stat = myDMA.startJob();

... results in clock frequency of 50.00 Khz

Being curious, I set the frequency to 8000 and measured 8.07 Khz, which tracks since I'm using the internal oscillator, not a crystal.

Other testing:

8000 Hz request --> 8.07 kHz output 46kHz request --> 46.89 kHz output 48kHz request --> 50.00 kHz output

Maybe I've made a silly error somewhere? I'm running the demo code otherwise unmodified.