Skip to main content
Visitor II
July 23, 2020
Question

ST-link/v2 with Keil debugging/flashing problems

  • July 23, 2020
  • 3 replies
  • 2886 views

I have built my own custom board with an STM32L412KB processor on board. I am using the ST-link /v2 to connect via JTAG to the board. I am able to connect with the ST-Link utility as well as Keil. In Keil I can compile and flash the code, but it seems there is some sort of problem.

I am able to enter debug mode, but if I put a breakpoint within the main function and click 'run to cursor', it gets stuck and the ST-Link flashes red/green indefinitely. However, in debug mode I can open the registers manually and change values (e.g. to make LEDs turn on/off etc).

Any advice or thoughts would be greatly appreciated as I am at a loss for what to do.

Thanks!

    This topic has been closed for replies.

    3 replies

    Graduate II
    July 23, 2020

    Where does it get stuck, hit the stop button and check.

    Is it in the Error_Handler or HardFault_Handler while loops? A BKPT because you're using puts/printf?​

    TRuss.2Author
    Visitor II
    July 23, 2020

    Thanks for replying. My main program is just one line:

    int main(void){

    RCC->AHB2ENR |= RCC_AHB2ENR_GPIOHEN;

    return 0;

    }

    In debug mode when I press 'stop', I see things happening in the registers and disassembly when I step by one line. I am not sure how I would tell if this is from the Error_Handler or HardFault_Handler.

    Here are some screenshots:

    TRuss.2Author
    Visitor II
    July 23, 2020

    To follow up I believe it's just a problem with the program getting hung up in the startup code and never reaching the main program for some reason.