2023-02-13 05:55 AM
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.
Solved! Go to Solution.
2023-02-14 05:41 AM
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
2023-02-13 07:40 AM
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
2023-02-13 10:38 PM
@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
2023-02-14 02:12 AM
Not by default. It has to be enabled:
https://interrupt.memfault.com/blog/cortex-m-hardfault-debug#configurable-usage-faults
2023-02-14 02:14 AM
for (;;);
Infinite loop is not a hard fault...
2023-02-14 05:41 AM
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
2023-02-15 12:45 AM
@KnarfB Thank you