cancel
Showing results for 
Search instead for 
Did you mean: 

Exception Handler

Sudhakar.R
Associate III

i try to crash my code to check the watchdog timer is reseting the code or not. for crashing my code i use timer interrupt. i.e

TIM2_IRQHandler()

{

---------------;

---------------;

}

TIM_IRQHandler() instead of TIM2_IRQHandler . so, code will be crash at that time watchdog timer should reset the my code and some Exception Handler is there.

Example,

1)Hardfault

2)MemManage

3)BusFault

4)UsageFault

how to make my code stuck in an exception handler.

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

Here is an excellent overview: https://wiki.segger.com/Cortex-M_Fault with code.

If you don't make your variables volatile, the compiler can optimize the div away, especially if b is a compile-time known constant. Disasm may help here too.

hth

KnarfB

View solution in original post

6 REPLIES 6
Nikita91
Lead II

On M3, M4 and M7 integer divide-by-zero generates a UsageFault exception,

So divide by 0 and set an infinite loop in the UsageFault handler

Sudhakar.R
Associate III

@Nikita91​ Thank you for your comment.

i tried divide by 0.

int a = 5, b = 0;

a=a/b;

but i'm not get infinite loop.

if you know any other method tell me

Piranha
Chief II
for (;;);

Infinite loop is not a hard fault...

KnarfB
Principal III

Here is an excellent overview: https://wiki.segger.com/Cortex-M_Fault with code.

If you don't make your variables volatile, the compiler can optimize the div away, especially if b is a compile-time known constant. Disasm may help here too.

hth

KnarfB

Sudhakar.R
Associate III

@KnarfB​  Thank you