cancel
Showing results for 
Search instead for 
Did you mean: 

ST-link/v2 with Keil debugging/flashing problems

TRuss.2
Associate II

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!

3 REPLIES 3

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?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TRuss.2
Associate II

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.2
Associate II

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.