cancel
Showing results for 
Search instead for 
Did you mean: 

Stack pointer for the STM32L151CB in STM32CubeMX

URaic
Associate II

I am working on the readout of a GPS module on the Rak811 tracker board featuring an STM32L151CB processor. My program showed very strange effects and after longish debuggginb I found out that the stack pointer was wrongly set at entry of me man program. The code was generated by STM32CubeMX. Did anybody else see this?

I could not find out where in the startup code the SP is set up but then I set it up myself immediately at the reset entry point everything works fine.

The strange this is that on a STM32F103C8T6 everything is correct also without my modification.

Uli

2 REPLIES 2

> I found out that the stack pointer was wrongly set at entry of me man program

SP is set by hardware at reset to the value given as first word in the vector table. Usually the linker according to its settings (through linker script or other toolchain-dependent mechanism). So you should look up the documentation of your toolchain and its settings to find out where lies the root of the problem.

JW

URaic
Associate II

Thanks! In fact I created the startup code for the STML151CB-A from STM32CubeMX thinking that the SP should be setup correctly before entering main. When creating the startup code in an Eclipse Ac6STM32 MCU project I see that the stack pointer is loaded in the first instructions of the reset handler. In the code generated by STM32CubeMX this code is missing. When I take it away I see the stack pointer at 0x200006a8 even though the first entry of the vector table is 0x20005000.

Is this a bug in STM32CubeMX?

Uli