Zero I2S – MCK output support?

Hello,

There is a line in Adafruit_ZeroI2S library that says “MCK pin output (unsupported on Zero).”

Do you know what is the reason for which I2S MCK output in unsupported on Zero? As far as I got it, the MCK[0] is on PA09, which is available on the connectors. I couldn’t trace the peripheral that could overtake it. So, again, do you know why it’s unavailable? And do you know if there’s any workaround? (In case that it’s just not available in the default configuration).

Best regards,
GregorioW

Hi,

Never mind, it seems that I just made a simple mistake. So, first of all, this pin is generally used by TCC0 (I have no idea why I said I couldn’t trace it). And once you replace the line 111, i.e.

i2s_clock_instance.mck_pin.enable = false;

with:

i2s_clock_instance.mck_pin.enable = true;
i2s_clock_instance.mck_pin.gpio = PIN_PA09G_I2S_MCK0;
i2s_clock_instance.mck_pin.mux = MUX_PA09G_I2S_MCK0;

it seems to work as intended. (I have no oscilloscope at the moment to check the actual signals but my converter, which requires MCK, is working.)

Have fun,
GregorioW

Hi,
I'm answering, because that's first and only accurate post about SAMD21 and I2S MCK.
I found it very helpful although not enough for TS4657, which needs MCK to be 256*LRCLK (or FS).
For this you have to change I2S Generic Clock prescaler in line 85ish from:

gclk_generator.division_factor = F_CPU / (sampleRateHz*numChannels*bitsPerSample);

to:

gclk_generator.division_factor = F_CPU / (sampleRateHz*256);

After that you need to set SCK prescaler to one corresponding to number of bits per sample: 8 for 16bps and 5 for 24bps in line 101ish:

	i2s_clock_instance.clock.sck_div = 8;

also I activated MCK out in line 99ish (I changed it from false to true):

	i2s_clock_instance.clock.mck_out_enable = true;

It works well with example sketch, with Fs=44.1kHz, 48kHz seams to be generated not as desired and is quite distorted. I tried it only with 16bps.