Skip to main content
teklike
Associate
November 15, 2018
Question

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

  • November 15, 2018
  • 4 replies
  • 1196 views

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?

This topic has been closed for replies.

4 replies

Pavel A.
Super User
November 15, 2018

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

-- pa

teklike
teklikeAuthor
Associate
November 16, 2018

​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
Super User
November 16, 2018

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
teklikeAuthor
Associate
November 20, 2018

​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:).

:smiling_face_with_smiling_eyes: