Author Topic: STM32 crystal choice and design  (Read 4043 times)

0 Members and 1 Guest are viewing this topic.

Offline BronnTopic starter

  • Newbie
  • Posts: 5
  • Country: au
STM32 crystal choice and design
« on: January 23, 2022, 12:11:37 am »
Hi, I just need a little help to double check if Im doing this right.
Im designing a breakout board for an STM32L431C8T6 and am trying to pick a crystal for the HSE oscillator. Ive been following the AN2867 Oscillator design guide as best I can.
So far I have been looking at this crystal.

MCU: https://datasheet.lcsc.com/lcsc/1811081824_STMicroelectronics-STM32L431CBT6_C277951.pdf

Crystal: https://datasheet.lcsc.com/lcsc/2008211535_JWT-CF4040M00015T8188060_C709171.pdf
design guide: https://www.st.com/resource/en/application_note/an2867-oscillator-design-guide-for-stm8afals-stm32-mcus-and-mpus-stmicroelectronics.pdf


relevant information on the MCU:
Quote
...For C_L1 and C_L2, it is recommended to use high-quality external ceramic capacitors in the 5 pF to 20 pF range (typ.)...
..Gm Maximum critical crystal transconductance = 1.5mA/V..

Using the formula from the guide I have
Code: [Select]
Rext = 0;
CL = 8e-12; % Load
C0 = 5e-12; % Shunt
f = 40e6; % freq
ESR = 30;
gm_crit_max = 1.5; %MCU
gm_crit = 4*(ESR + Rext)*(2*pi*f)^2*(C0+CL)^2 * 1000 % mA/V

Code: [Select]
>> gm_crit =

    1.2810


So since 1.281 < 1.5 this should be ok?


A couple of concerns.
The crystal data sheet states only 1 value of C_L as 8pF for the whole range from 8MHz - 54MHz. Im worried they only gave a value for the lowest frequency and the frequency Im using may be more than this?

And the other problem is Im not sure how to calculate the R_ext value, if its needed. The design guide requires measuring the current which I can't really do.
How do you go about choosing a crystal if you can't do this measurement? It seems common to choose 0Ω but Im not sure if I can make that call since this is much higher speed than all YouTube examples Ive seen.


Thanks

« Last Edit: January 23, 2022, 12:15:37 am by Bronn »
 

Offline betocool

  • Regular Contributor
  • *
  • Posts: 96
  • Country: au
Re: STM32 crystal choice and design
« Reply #1 on: January 23, 2022, 02:19:51 am »
I've done a few STM32 designs on different families.

For ease most of the time I chose an oscillator. However, since that is not your question, in cases where I've used crystals, I took the design guide as reference / rule of thumb. So, for a 25Mhz crystal, off the top of my head, I'd have gone with 18pf I believe, with 33R or 50R series resistor. Good thing about resistors, you might not even really need them, so you can add a bridge if that is the case.

One thing, both caps I used where always the same value, do I understand correctly that you're using 5 and 8 pf?

Cheers,

Alberto

 

Offline BronnTopic starter

  • Newbie
  • Posts: 5
  • Country: au
Re: STM32 crystal choice and design
« Reply #2 on: January 23, 2022, 02:31:04 am »
Thanks.
I hadn't calculated the load capacitors yet but if I wanted CL= 8pF and using assumption that C_stray = 5pF then I guess I would be using a pair of 2(8-5) = 6pF?

At the moment Im just trying to see if the MCU can start up and run this crystal safely. I have used out of the box values/crystal I borrowed from YouTube on other designs but for this one I thought I would try and go through the process myself and pick a crystal.
 

Offline BronnTopic starter

  • Newbie
  • Posts: 5
  • Country: au
Re: STM32 crystal choice and design
« Reply #3 on: January 23, 2022, 02:57:46 am »
Thanks

Quote
Just a general comment -- you did well getting the relevant application note and following its guidance.
But from a practical "confirming typical design details" standpoint, it would be wise to also download all of the
application notes / CAD resources relevant to developer kits and reference design PCBAs and "minimal BOM" type
publications.  I assume there would be at least one devkit, one or more reference design boards, and maybe a minimal BOM / circuit example related AN.
I did check out some Nucleo boards designs. I couldn't find any that used frequencies above 16MHz and the crystals in that range seemed to fit well below specs. I guess just this crystal is kinda on the edge of the values is what brings uncertainty to me. Furthermore, I m planning to use JLCPCB's assembly option so I'm limited to their stock and can't exactly pick the same components from Nucleo BOM.

Quote
Anyway my other point is because it isn't an exact science to pick the right capacitor value you should guess the right one from the calculations and reference designs / application notes and try it but maybe due to your particular PCB or whatever you'll actually do better with a slightly different value couple pF either way in which case you can measure the actual oscillation frequency against a GPS PPS signal or something or cheap $10 calibrated TCXO frequency counter and then tweak the capacitance up or down as needed.  It'll probably work fine with a range of values but maybe you'll be a few ppm off one way or another depending on the crystal and circuit etc.
Yeah, I guess worst case I can just desolder parts and use components/values I know will work.


Quote
The AC amplitude of the oscillation drive voltage applied to the crystal by the MCU should be specified by the MCU data sheet for a given MCU supply operating voltage.
Ive tried searching for this value. Maybe I just don't know what I'm looking for, what is it listed as? Is it in the section Ive attached? is it just Vdd?


Thanks for the suggestions, Ill have to go through them in detail.
« Last Edit: January 23, 2022, 02:59:35 am by Bronn »
 

Offline julian1

  • Frequent Contributor
  • **
  • Posts: 731
  • Country: au
Re: STM32 crystal choice and design
« Reply #4 on: January 23, 2022, 11:05:53 pm »
I went down the same rabbit hole trying to calculate xtal currents following stm32 design guidance,

https://www.eevblog.com/forum/beginners/santity-check-units-is-10uw-a-plausible-drive-level-for-mcu-crystal/msg3417874/

The way I approach it now, is to just include an optional footprint for an extra series resistor, and then probe the osc amplitude.

If the current/ amplitude is too large (ie greater than 2-2.5V) then add some series resistance. In general, smaller physical crystals - ie smt versus through-hole crystals have higher ESR.  And lower freq (8MHz v 16MHz) will also have higher esr. In practice for 8MHz and small smd xtal with a 0R series is fine. I forget, but ST (or maybe someone else?) already adds some series resistance to the cmos driver.

For caps, the value depends on the xtal loading capacitance, and board trace stray capacitance - which is almost always reasonably constant. In practice - if one picks crystals with the same loading capacitance regardless of manufacturer part, formfactor or freq, then one can use the same cap values between designs.


 
 
The following users thanked this post: Bronn


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf