2018-11-15 11:06 AM
I generate a project for processor: STM32L4A6VGT6 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?
2018-11-15 02:03 PM
This is strange. SystemClock_Config should be called very early, not the last thing before while(1).
-- pa
2018-11-16 09:15 AM
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?
2018-11-16 12:36 PM
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.
2018-11-20 09:03 AM
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: