cancel
Showing results for 
Search instead for 
Did you mean: 

Moving SystemClock_Config Causes Strange Erros

Konami
Senior

I know this is a vague question, but it's a very strange problem I'm facing. My application (based on STM32G0) is working fine. I used CubeMX to autogenerate all the code, and have been building on top of it. Now I am looking to clean things up a bit so code is better organized and I changed my SystemClock_Config() to a static function. By making this simple change, my code has stopped working. I haven't dug into the exact nature of the failure yet, but it seems like some of my timers may not be running correctly.

The only change is that instead of calling the SystemClock_Config() function from main(), I call a System_Init() (on the same line in main) which then immediately calls the now static SystemClock_Config().

I suspect there's some other underlying issue that was being masked previous, but this got me thinking of what would this even change that could have any impact on the application. So with that, I have 2 questions:

  1. Any ideas where the heck to start looking?
  2. What impact could calling the exact same function through a wrapper have? Seems to me the only thing it would change is an additional function call overhead.

1 REPLY 1
TDK
Guru

Making SystemClock_Config a static function won't cause it to behave differently. Look into what "code has stopped working" means in particular. Stay objective, don't guess at solutions that don't make sense.

If you feel a post has answered your question, please click "Accept as Solution".