code gets stuck on SystemClock_Config() or HAL_Delay() when using External clock
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-07 1:04 AM - last edited on ‎2025-04-07 2:17 AM by Andrew Neil
When ever I configure HSE in my ioc file for my custom PCB my code stops at SystemClock_Config() or HAL_Delay().
One time when I replaced 48Mhz crystal oscillator with 32 Mhz my LVCU code worked on HSE but it was considerably slow than HSI even on 170 Mhz.
When I created another project to test HSE the same problem continues i.e SystemClock_Config() and HAL_Delay() stopped .
Can some one tell what should be the ioc file setting for HSE so that SystemClock_Config() and HAL_Delay() works.
(LVCU working,distance2 not working)
Solved! Go to Solution.
- Labels:
-
STM32G4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-10 1:30 AM - edited ‎2025-04-10 1:50 AM
Hello,
Is this the part of crystal in the schematics?
10kOhm (I think R16) as series resistor? Are you sure?
Did you calculate it according to what AN2867 stated?
According to the values in the schematics and what the AN stated:
Rext = 1 / (2 x PI x 48MHz x 30pf) = 110 ohm
So 10K is a very big value.
Then you need to recalculate the gain margin (as stated in the application note).
Also RExt needs to be 0 ohm unless you find the crystal is overdriven:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-07 1:53 AM - edited ‎2025-04-07 1:55 AM
Hello,
1- I can't see any difference between both ioc files.
2- I'm confused. You said you are using 48MHz and 32 MHz crystals but in the CubeMx configuration you set the crystal value to 16 MHz in both projects. Could you please check and confirm?
3- Did you also verify if your crystal is compatible with your MCU? please refer to the AN2867 "Guidelines for oscillator design on STM8AF/AL/S and STM32 MCUs/MPUs"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-07 2:38 AM
1- Yes, I tried to replicate the correct ioc file.
2- sorry for the confusion , recently I also tried 16 Mhz crystal oscillator and the results were the same.
3- Yes I verified , the crystal is compatible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-07 2:45 AM
The issue still not clear,
1- I propose to share your schematics especially the HSE part.
2- Need to specify which function in SystemClock_Config() is failing, HAL_Delay() is just called in the Error_handler(). Try stepping your code to know when Error_handler() is called.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-07 7:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-07 7:48 AM
Please attach the schematic in pdf format.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-08 3:49 AM
This is schematic pdf.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-08 6:17 AM
Hello,
This is not the schematic but the PCB layout:
A schematic looks like the following:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-08 8:11 AM
schematic is below PCB layout.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-08 8:16 AM
Sorry I didn't see it.
But the schematics has a very bad resolution. I can't even read the part numbers in the schematics.
Please attach a screenshot of your schematics with a good resolution.
Thanks
