简体   繁体   中英

STM32L-Discovery step-by-step debugging

I'm using STM32L-Discovery with STM32L152RBT6 onboard with CoIDE. I've created new project, picked STM32L152RBT6 microcontroller and added following components:

  • C_library
  • cmsis_core (which as far as I can see contains boot)
  • STM32L152xB_CUBELIB

Now I'm trying to perform step-by-step debugging of this very simple code:

int main(void)
{
    int var1 = 1;
    int var2 = 2;

    while(1)
    {
        var1 = var1+1;
        var2 = var2*var1; // breakpoint here
    }
}

It compiles, loads, but when debugging step-by-step the compiler ommits lines of code. When running from breakpoint to breakpoint the program acts totally crazy and var1 and var2 values seem to be random. Compiler toolchain: GNU Tools ARM Embedded 4.9 2015q2

I've got another board with STM32F4xx uC where it works fine. Hey, community, do you have any ideas what's wrong?

Sorry, my reputation is not enough to comment to a question, so the only way to help you is writing my response in the answer box, although I'm fully aware of the fact that this may not a complete answer.

There may be several reasons for such a behavior. Unfortunately there are not much details in your question for me to give you a straight answer. Wrong micro selection would be my very first guess. STM32L152RBT6 is a Cortex M3, and perhaps you are trying to load a program that is compiled for M4 to an M3 family device. If you have done so, micro initialization will be wrong and can lead to some undefined behavior.

What are the debuggers that you are using in both cases? In the case of discovery board, I would automatically assume you are using the in built STLink. What about the other board that has M4 family micro in it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM