AnsweredAssumed Answered

SystemInit is not called as expected

Question asked by on Jun 26, 2015
Latest reply on Jun 26, 2015 by Clive One

 Dear community,

if I look for the contents of the startup.s file of e.g. a STM32F373RB firmware then I recognize following lines:


                 LDR     R0, =SystemInit   ; load a word into R0 e.g. the address of SystemInit

                 BLX     R0                               ; link and branch to address stored in R0

                 LDR     R0, =__main           ; load a word into R0 e.g. the address of main

                 BX      R0                                ; branch to address stored into R0


If I understand this code correctly then SystemInit should be called first, followed by main. I introduced a USER_var into the SystemInit to see how it is executed. In the main – section I introduced a routine to output USER_var.

My findings are that USER_var can be initialized with a certain value e.g. int USER_var = 10; however if I assign other values e.g. inside the SystemInit() or SetClock() function to check what exactly happens there, I doubt this function is not called as expected. If I call SystemInit() from main then I can see that it is really executed as expected. Since I use the KEIL compiler it might be a specific problem with the compiler however maybe someone here knows what happens. I would be very happy if someone would post her/his opinion.