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.
Solved! Go to Solution.
2025-08-23 9:02 AM - edited 2025-08-23 9:02 AM
>Suggestions welcome and anyone who can help solve this
So i try.... (seems you didnt build something like this, so problems first):
1. if you want a standard USB (UAC1 , 48kHz, 16b, stereo/2 ch ) codec interface (AD in + DA out ), you have to deal with the clock : master is the PC, so your device has to get its clock by a PLL from the 1ms timing on the USB bus.
DAC only is no problem , PCM5102 can do this (internal PLL); but ADC...i dont know.
2. to see, what you can do on the software , to get it enumerated as standard audio interface in Win, Linux or Mac, buy a cheap board with the target cpu you want and try to get a working software on it;
board should be with debug interface, so i recommend: a nucleo board, with USB .
cheapest maybe : NUCLEO-H533RE , 13,64 € at Digikey (next week avail.) - or anywhere.
or NUCLEO-H753ZI or NUCLEO-H563ZI , about 25 € .
3. use theSTM32CubeIDE , generate a design with the cpu you want to do it, then set it to I2S in/out and the USB to device -> audio . Then try to start compiler and make a program....if it looks good, you ready to buy a board with these cpu and test it for real.
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.
2025-08-23 5:32 AM
Hi,
maybe good, if you tell (me) , what you want to build - generally fundamentally : an audio player ?
or a USB sound card with some DSP processing inside ?
+ 1701 ...is ADAU1701 ? ( i assume) + cpu is ..?
btw
I made an audio player with H743 and ES9038 DAC (and other dacs...), plays from SD-card and USB.
2025-08-23 6:16 AM
2025-08-23 9:02 AM - edited 2025-08-23 9:02 AM
>Suggestions welcome and anyone who can help solve this
So i try.... (seems you didnt build something like this, so problems first):
1. if you want a standard USB (UAC1 , 48kHz, 16b, stereo/2 ch ) codec interface (AD in + DA out ), you have to deal with the clock : master is the PC, so your device has to get its clock by a PLL from the 1ms timing on the USB bus.
DAC only is no problem , PCM5102 can do this (internal PLL); but ADC...i dont know.
2. to see, what you can do on the software , to get it enumerated as standard audio interface in Win, Linux or Mac, buy a cheap board with the target cpu you want and try to get a working software on it;
board should be with debug interface, so i recommend: a nucleo board, with USB .
cheapest maybe : NUCLEO-H533RE , 13,64 € at Digikey (next week avail.) - or anywhere.
or NUCLEO-H753ZI or NUCLEO-H563ZI , about 25 € .
3. use theSTM32CubeIDE , generate a design with the cpu you want to do it, then set it to I2S in/out and the USB to device -> audio . Then try to start compiler and make a program....if it looks good, you ready to buy a board with these cpu and test it for real.