0
\$\begingroup\$

I am currently building an audio guitar pedal. I was suggested to use an external clock as reference for my CODEC and MCU. I've been reading the "Oscillator design guide for STM8AF/AL/S, STM32 MCUs and MPUs" application note for a while now. I am trying to understand which oscillator best fits my MCU, however I am not able to find a good external clock that matches the requirements they pose in the guide.

I am mostly looking for a HSE of about 25 MHz, since I am working with audio.

I would appreciate it if I could get some recommendations for external clocks that would work for my project.

In terms of the capacitor values I can use the guide to figure that out.

Thank you in advance,

\$\endgroup\$
2
  • \$\begingroup\$ Why would the crystal need to be 25MHz for audio? Yes, it will be difficult to find a suitable 25MHz crystal, it's just that why you would even want a 25MHz crystal to begin with. Also, are you looking for a crystal, or oscillator? \$\endgroup\$ – Justme Apr 7 at 8:09
  • \$\begingroup\$ You did not provide clarifications to my above comments and you started a new question which confirms that you have an XY problem - With theu current question you are basicallly seeking recommendations which 25 MHz crystals to buy and from where to buy them because you think you need a 25 MHz crystal, and you don't actually even need or want a 25 MHz crystal to begin with. Voting to close. \$\endgroup\$ – Justme Apr 8 at 6:34
0
\$\begingroup\$

Her's Digikey selection filter for a quartz crystal working at 25 MHz with frequency stability of +/- 10 ppm which is very good:

https://www.digikey.com/en/products/filter/crystals/171?s=N4IgjCBcoKwMwHYqgMZQC4CcCuBTANCAPZQDa4cAnABwgC6hADulCAMpYCWAdgOYgBfQgCYwMAAzIQaSFjyESkcsJgACALIAJAF70mLSCACq3TugDyAM3W4AhgGdsmXIIECgA

\$\endgroup\$
0
\$\begingroup\$

If you have STM32Cube or STM32CubeIDE, you can play with various crystal frequencies and see if you can generate the required internal frequencies for various peripherals. If you are using I2S, SAI or SPDIF the clock frequency you need will depend on the sampling rate of of the codec and what the multiplier for MCLK is. These programs will also automatically calculate the internal parameters for the PLLs needed to generate the audio frequencies and determine what the error is.

All of this is separate from the HCLK value which is the frequency the processor runs at.

The H446 has 2 PLLs which can be used to generate faster or slower clock frequencies from the crystal by multiplying and dividing the clock frequency.

For example, if you are going to use 44.1Khz as your sampling frequency and a 25MHz crystal, the closest you can come to 44.1Khz is 43.989Khz (0.02% error). If you are going to use a 48KHz sampling frequency, the error is -0.27% which would probably not be ok for a high-end audio application.

Regardless of which crystal you use, you can come pretty close to the 180MHz maximum for HCLK (processor code execution clock). There are crystals made with "odd" frequencies that allow for exact generation of common audio sampling rates.

\$\endgroup\$
4
  • \$\begingroup\$ Interesting. I was thinking of using SAI or I2S, the CODEC in consideration is the PCM3060, however I was thinking of using instead ADCs (PCM4220, TLV320ADC6140), and DACs (PCM5xxx) from the TI portfolio. In this case, would an external reference clock be needed? or will an internal clock from the MCU be enough? The target sampling frequency is 44.1 kHz. I am not sure how you calculated the error %, could you please elaborate a bit more? What would be an ideal sampling error % for high-end audio? Thank you. \$\endgroup\$ – dcm Apr 7 at 14:56
  • \$\begingroup\$ @vzdiegocm Idea is that you cannot produce arbitrary sampling frequency using fixed clock. The PLL typically has limited range of values for multipliers/dividers, only a set of frequencies is possible to generate, and if you use 25MHz crystal you cannot get precise 44.1kHz, you can get something quite close, but not exact. In order to get precise sampling frequency you need to find a crystal with a frequency that will allow to produce the exact frequency you need after all multiplications/divisions. Or you can stay with the error if your hw can tolerate that. \$\endgroup\$ – Vlad Apr 7 at 20:16
  • \$\begingroup\$ Ok, am starting to understand. Is it possible if you could provide me with some resources to understand this concept a bit better? Maybe some indication as to what I could google to get a better idea of how to approach this problem? \$\endgroup\$ – dcm Apr 7 at 20:31
  • \$\begingroup\$ Download the STM32CubeIDE, it is free and has a graphic clock calculator and solver. Playing with values on the clock tab will probably be the easiest way to see what the hardware is capable of. \$\endgroup\$ – Dean Franks Apr 12 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.