cancel
Showing results for 
Search instead for 
Did you mean: 

Project generated by STM32CUBE-MX does not execute past the initializations

teklike
Associate II

I generate a project for processor: STM32L4A6​VGT6 and open it in Atollic TrueStudio and start debugging with ST-Link (V2).

The processor excutes, stops at main, as it should. I can step through the initializations correctly. After the last function (in a very simple project) the SystemClock_Config() function starts execution and at the end of this funcion, instead of going to the next C instruction of "while(1) " the processor goes somewhere from where it does not return

Am I  missing some a step in using the CubeMx generated project in TrueStudio?

4 REPLIES 4
Pavel A.
Evangelist III

This is strange. SystemClock_Config should be called very early, not the last thing before while(1).

-- pa

teklike
Associate II

​The setup is intentionally extremely simple to bring focus to the problem. I am creating the STM project for TrueStudio without any changes ( no peripherals are activated, no changes to the RCC (so the processor coming out of reset is running on MSI clocks).

The one additional observation is that when I look at the dis-assembly (with source code viewing enabled) I see the main, HAL_init, SystemClock)_Config, but after that I do not see the while (1) loop. 

It seems that although Cube is generating the source code for the while loop, the cross compiler is not compiling it? 

Also when I add any code manually to the source file the dis-assembly does not show it, and when I try to set a break point on this added code, the debugger says those lines do not exsit.

Am I missing a setting in the TrueStudio?

  

Bob S
Principal

Is there anything IN the while(1) loop? If not, the compiler may very likely optimize it away and go straight to the (implied) return at the end of main(), which is an infinite "branch here" instruction in the startup code. Posting code could be helpful.

teklike
Associate II

​Excellent observation!

I turned the optimization to "none", and now I can see the while(1) instruction in disassembly window and  the execution continues on to the while loop:).

��