This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems single stepping in Keil uVision

I've been trying to debug mbed (2) code in Keil uVision, but only with limited success.

I am using the Nucleo F401 board from ST. At the time of writing, I have the latest version of Keil uVision, ST Link Drivers and Firmware - all packages are up to date. The OS I use is either Windows 7 (64) and Windows 10 (64).

- I export an mbed project fro mbed.org for Keil v5
- Open the project
- Set optimisation to -O0
- Rebuild
- If I build, download and run, all is well. When switch to debug mode, I can add a breakpoint and run the code - that's fine.

The problem is when trying to single step the code. Step-in seems to work, but I don't want that behaviour. I want to step a line at a time without stepping in.

(Note - I close the disassembly listing, and only view the C source)

Sometimes it works, other times the code seems to run away* ( as if I'd clicked the run button' ). I would understand this if optimisation was turned on, but it's off.

I've experimented with different settings with no success (I'm at the point where it's descended into a frustrated and crazy-eyed random clicking of options!).

What is odd is that it used to work. I've tried other boards with older firmware as well.

Anyone have the same / any suggestions?

Parents Reply Children
  • For Cortex-Mx parts a frequent destination is the while() loop forming the Hard Fault Handler, or the dumping ground for the unprovisioned IRQHandlers

    Remember also if the IRQ source isn't cleared that Handlers will tail-chain indefinitely and no foreground execution will occur.

  • So here is a very trivial example:

    1. #include <mbed.h>
    2.
    3. DigitalOut myled(LED1);
    4. BusOut b(D7,D6,D5);
    5.
    6. int main() {
    7.
    8.   myled = 1;
    9.   wait(1.0);
    10.  myled = 0;
    11.  wait(1.0);
    12.
    13.  while(1) {
    14.     b = 1; // LED is ON
    15.     wait(0.2); // 200 ms
    16.     b = 3; // LED is OFF
    17.     wait(0.5); // 1 sec
    18.     b=7;
    19.     wait(0.2);
    20.  }
    21. }
    

    I put a breakpoint (BP) on line 8,9,10 and 11. I enter debug mode, and click the run(F5) button 3 times - great - all ok, each line runs to completion and stops at the next BP.

    Now, I only put a BP on line 8. Run the code and it stops on line 8 as before.
    When I press F10 (step over), and it branches to line 6 (?!?). I press again and it never returns. I stop (pause) execution and it's (for example) on line 19 (or inside).

    It behaves as if the next breakpoint is not being set.