cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Hardware for external clock

DElec.1
Associate II

I want to develop my own PCB using STM32F4. I want to use one external clock (16 MHz). I wonder where I have to connect the clock: OSCIN32-OSCOUT32 (pins 3 and 4) or OSCIN-OSCOUT (HSE) (pins 5 and 6 in STM32F446RET).

I can see in the development board's schematic how there is an empty footprint for X3 (pins 5 and 6) and I don't know if it is using the debugger's clock.

Thanks in advance.

7 REPLIES 7
Jaroslav JANOS
ST Employee

Hello,

the OSC32 pins are for LSE (32kHz) oscillator, so in your case it is the second pair.

For more information about PCB design guidelines for oscillators refer to AN2867 (https://www.st.com/resource/en/application_note/cd00221665-oscillator-design-guide-for-stm8afals-stm32-mcus-and-mpus-stmicroelectronics.pdf).

Jaroslav

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.

DElec.1
Associate II

Ok, thank you. I did not know if it were necessary to add two capacitors even if you just want the HSE one. I was having some trouble trying to run code and I think it had to do with the oscillator.

The NUCLEO / DISCO boards typically source an 8 MHz crystal based source from the ST-LINK's MCO output.

Watch for solder bridges or zero ohm routing of signal.

H​SE should use BYPASS mode for external clocks. Use OSCIN only. Check is source or TCXO expects capacitive loading.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

In my PCB I use an external 16 MHz crystal oscillator connected directly to the OSCIN-OSC-OUT pins. The schematic includes two capacitors (value = 2 * (Cload - Cstray) = 26 pF). Do I need to set anything special (apart from basic clock configuration, input, freq, etc) in STMCubeIDE?

0693W00000Sw5naQAB.png 

Regarding your schematics, I would definitely NOT recommend you those jumpers J2 or J3 - keep the tracks between MCU and the oscillator as short as possible to reduce capacitive and inductive effects. Otherwise the oscillations might be unstable.

Try to follow the application note...

In the CubeMX, just enable the HSE in RCC menu and configure the clocks on the "Clocks" tab accordingly (selecting the HSE, setting PLL/dividers etc.).

Jaroslav

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.

Also, the load capacitors C5 and C6 seem to be much too large, moreover, each crystal typically requires different capacitor values, especially if the crystal frequency differs greatly.

Please follow the mentioned AN2867 for the capacitors, also section 7 is very important because there is a lot of layout information. As Jaroslav said: make the tracks between crystal and STM32 as short as possible and also avoid vias.

Regards

/Peter

In order 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.

Cross-linking related https://community.st.com/s/question/0D53W00001pIaLwSAK/stm32f4-hardfaulthandler-haltimeout-errors

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..