cancel
Showing results for 
Search instead for 
Did you mean: 

HSE clock lagging above 16 Mhz

ChaitanyaParate
Associate II

I am using 30 Mhz crystal oscillator, and when I configure clock for 30 Mhz it doesn't work properly but when I configure 16 Mhz it works properly.

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

@ChaitanyaParate 

Please review this new article: How to select a compatible crystal and load capacitors for STM32 with layout guidelines

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

11 REPLIES 11
alfsch
Associate II

Using 30M as a crystal is /maybe  a problem : many crystals (over 20M or so) are made as overtone crystals, most 3. harmonic, so your 30M crystal might be a 10M crystal, thats used on 3. overtone.

If using such a crystal in standard oscillator circuit, it will run at 10M.

So better stay with lower (=standard) frequency crystals, 8 or 16 MHz , and you have a reliable clock.

If you need 30 or 40 M oscillator (why ? ) , then be sure to have not a model for use at overtone and have the load caps very small, to get it running at all.

mƎALLEm
ST Employee

Hello,

Is it the same behavior as the other thread ?

If yes start by reviewing the compatibility of the crystal by referring to the AN2867 and calculating the gain margin:mALLEm_0-1744619426448.png

 

Do you get the gain margin > 5 based on what do you have in the HW?

what do you mean exactly by lagging? running at low frequency?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@ChaitanyaParate wrote:

I am using 30 Mhz crystal oscillator, .


Do you mean a crystal oscillator - or just a crystal ?

Difference between just a crystal, and a crystal oscillator.

 


@ChaitanyaParate wrote:

 it doesn't work properly 


What, exactly, does that mean:

  • fails to oscillate at all ?
  • does oscillates, but at wrong frequency? If so, what frequency?
  • bursts into flames ?
  • other ... ?
A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Its a crystal oscillator .

and by lag i mean when i put HAL_Delay(1000) I get a delay of almost 3 seconds when using 30, 32 , or 48 Mhz crystal oscillator.

Hello,


@ChaitanyaParate wrote:

Its a crystal oscillator .


Are you sure?

If yes, in that case you need to configure HSE in Bypass mode:

mALLEm_0-1744629414083.png

That configures one input GPIO for the crystal oscillator:

mALLEm_1-1744629470703.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

after selecting Bypass code is entering Error_Handler() in line 

HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK

 

 

Hello;

Is it the same crystal and the same project as this thread? if yes why did you accept it as solution? Please clarify this point. Is it the same project?

And this is NOT a cystal oscillator but this is only a crystal.

mALLEm_0-1744636144417.png

Did you replace R16 by a solder bridge?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

So look into HAL_RCC_OscConfig and see what is causing it to fail.

What result is it returning?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Yes it is the same project and i accepted it as solution.

I replaced R16 with 110 ohm resistor.