2019-01-05 04:16 AM
I am trying to debug the program using ST link on the board STM32F0308-DISCO. But after adding a breakpoint the Truestudio don't stop at the break point
Solved! Go to Solution.
2019-01-05 05:47 AM
Easy peasy: Change in the project settings the compiler optimisations. It's there regardless of the toolchain. Set that to none or minimal and you'll be able to put breakpoints in the unoptized machine code. When optimized, most of the assembly machine instructions have been factorized so much that breakpoints can't be placed where you wished for.
And if you need to keep the optimizations on?
volatile uint8_t always_zero = 0;
(...)
your code
if(always_zero)
{ asm("nop/n"); } // this code will be executed only if you stop the code, change the variable to non zero... in debug mode only. can be used for many fun things....
2019-01-05 05:47 AM
Easy peasy: Change in the project settings the compiler optimisations. It's there regardless of the toolchain. Set that to none or minimal and you'll be able to put breakpoints in the unoptized machine code. When optimized, most of the assembly machine instructions have been factorized so much that breakpoints can't be placed where you wished for.
And if you need to keep the optimizations on?
volatile uint8_t always_zero = 0;
(...)
your code
if(always_zero)
{ asm("nop/n"); } // this code will be executed only if you stop the code, change the variable to non zero... in debug mode only. can be used for many fun things....
2019-01-05 06:46 AM
Or the code simply doesn't get there?
__asm("BKPT #0\n");
Perhaps add telemetry via a USART so you can establish flow and function.
2019-01-06 08:19 PM
This worked for me! Thanks.
2019-01-09 07:32 AM
In TrueStudio I'm unable to step to next line when using software breakpoints? Is that OK?