2025-08-22 2:53 PM
I'm finalising a design with an AD1701 using the STM32 as the USB-audio driver (it's a modular, mix and match design but the STM32 is the most appropriate for the "reference design".
And herein is the issue, for a decent sample rate of 48 or 96 KHz (not audiophile but good enough) an accurate master clock running at 12,288 MHz which I can't get from the 1701 and in any case throwing that sort of frequency down jumpers is likely to end up in the board getting hoisted by a few kilograms of a home-made petard.
CubeMX calculates the error as high as 1.72% for 96 KHz for example with a 25 Mhz HS clock input.
I'm a little confused (I hail from the days when CPUs ran at 4-8MHz and we thought they were fast) so it might be my age but I don't understand how to correct this sort of error. I'd appreciate if someone more knowledgeable about I2S (or the SAI peripherals) of how to best ameliorate this issue.
I know how PLLs work to lock onto a signal but I'm out of my depth (I'm primarily a writer and design is largely a hobby for my own education). Mostly I'm confused on what effect the error will have on the recorded audio. I wonder if I'd be better of generating a 12.288 MHz from a simple Xtal oscillator using a Pierce oscillator and be done with it?
At least I can control both devices from a single master but I'm honestly baffled what this clock drift does.
2025-08-22 4:06 PM
Here you can find professional help for your STM32 project.
2025-08-22 4:49 PM - edited 2025-08-22 4:51 PM
Thanks Pavel, I'm familiar with Fiver but as an Open Source developer, part of the job is "learning on the job" - I do this for my own enlightenment and education. It's nostalgic - at least it would be if these things didn't run like a rocket-powered cheetah. But I do enjoy getting my hands dirty again - from design to final product. The big difference now is my PCBs at least look like some thought went into them.
I may well have to hire someone to get the STMF7 to act as a composite USB device, since that's totally beyond me. USB simple on the outside but a nightmare on the inside, amirite?
I've figured the best solution [at least to the master clock] is to use a simple Schmitt inverter with a 12.288 MHz crystal and use a couple of buffers to supply the master clock to both devices simultaneously. On of the spares might come in handy as a short reset monostable too. This seems to be a better solution so I can use any one of several STM32 MCUs without too much trouble, The 1701 might be able to output a master clock (I haven't looked that close) but using the same central clock for both devices should eliminate jitter and keep everything in concert, even if the USB drifts - we all have to suffer that.
Course designing a reliable Pierce oscillator looks deceptively simple, I'm going to have to dig in a bit to make sure this thing works first time (every time).
Looks like an alternative (though potentially "hidden rake" option would be to buffer the sine wave from the 1701's xtal with a Schmitt buffer (available in SOT23-5 so potential if I run low on board space.
I'm still in the dark about the sampling and internal clocks where I2S is concerned so if anyone is able to help, solutions gratefully received with thanks.