cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop executing program/halt the CPU

bartra
Associate

One of our project has problem, not easy to find, because of nonregularity of occuring in unknow part of code (it hasnt been reproduced in controlled way). I would like to write macro, that will replace every call of problematic part of code (which is called in a lot of different places in code) by additional if() statement, that will prevent from doing unallowed things by writing through console name of file and number of line in case of error and halt the processor (I dont want to keep running this program after error). How can I stop executing program?

Or maybe there is anothere way to do something like this?

Regards,

5 REPLIES 5
MM..1
Chief II

How helps halt? Why no debug breakpoint on if?

Uwe Bonnes
Principal III

Tracing is another way to tackle that problem.

A breakpoint instruction would stop in the debugger​, or generate a Hard Fault without one, stopping in the while() loop their blocking execution and interrupts.

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

while (1); will also keep the processor busy forever. Disabling interrupts, resetting DMA, timers, other peripherals may also be wise depending on your program and needs.

If you feel a post has answered your question, please click "Accept as Solution".

STM32Cube_FW_F7_V1.16.0\Drivers\CMSIS\Core\Include\cmsis_gcc.h

/**

 \brief  Breakpoint

 \details Causes the processor to enter Debug state.

      Debug tools can use this to investigate system state when the instruction at a particular address is reached.

 \param [in]  value is ignored by the processor.

         If required, a debugger can use it to store additional information about the breakpoint.

 */

#define __BKPT(value)            __ASM volatile ("bkpt "#value)

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