cancel
Showing results for 
Search instead for 
Did you mean: 

Why does CubeMX code for SystemClock_Config give error

GreenGuy
Senior III
Posted on July 10, 2018 at 01:10

I am comparing an application project for stm32H7 with a project created from CubeMX that is meant to replicate the application project function.  The CubeMX project fails to run and I suspect a problem with the setup and initialization.  Comparing the SystemClock_Config function in main from CubeMX with the application project matching function I see a minor difference which when I try to correct the CubeMX code throws the execution into the _Error_Handler which points to a failure of the HAL_RCC_OscConfig() function.

0690X0000060LdlQAE.png

The error was caused after I commented out the CubeMX code and lines 249 and 253 and entered the code at lines 248 and 250 which match with the application code.  The other PLL values being set also do not match with the application but I do not think this relevant (correct me if I am wrong). 

I do not understand why the system is picky about the HSI_OFF and CSI_OFF settings when they are not being used to drive anything anyway.

1 REPLY 1
Posted on July 10, 2018 at 01:48

I'd definitely recommend clearing these structures.

I don't think the code is smart enough to know if you enable/disable things, you set a bit flag saying you want it to touch HSI and HSE, and it copies several fields together and writes them to a register. Some things it range checks and generates an error, but don't assume it catches everything, or that the stack is clean.

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