简体   繁体   English

STM32L-发现分步调试

[英]STM32L-Discovery step-by-step debugging

I'm using STM32L-Discovery with STM32L152RBT6 onboard with CoIDE. 我正在使用带有CoIDE的STM32L152RBT6和STM32L-Discovery。 I've created new project, picked STM32L152RBT6 microcontroller and added following components: 我创建了一个新项目,选择了STM32L152RBT6微控制器,并添加了以下组件:

  • C_library C_library
  • cmsis_core (which as far as I can see contains boot) cmsis_core(据我所知,其中包含启动)
  • STM32L152xB_CUBELIB 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. 从断点到断点运行时,程序的行为完全疯狂,并且var1和var2值似乎是随机的。 Compiler toolchain: GNU Tools ARM Embedded 4.9 2015q2 编译器工具链:GNU Tools ARM Embedded 4.9 2015q2

I've got another board with STM32F4xx uC where it works fine. 我还有另一块使用STM32F4xx uC的板,它可以正常工作。 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. STM32L152RBT6是Cortex M3,也许您正在尝试将针对M4编译的程序加载到M3系列设备。 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. 对于发现板,我会自动假定您正在使用内置的STLink。 What about the other board that has M4 family micro in it? 那里面有M4系列微型芯片的另一块呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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