cancel
Showing results for 
Search instead for 
Did you mean: 

Return from Exception Handler

pratik
Associate
Posted on February 10, 2016 at 13:21

Hi,

I am using STM32F439 Eval board. I am trying to understand Micro. supported exceptions. I want to know, Is there anyway to come back to normal operation once we get any exception.

lets assume i am doing division operation and  divisor happen to be ''ZERO''. so in this case, i would get usage fault exception and corresponding handler will get invoked.

now in Handler i am clearing

DIVBYZERO bit(by writing 1). 

So as per my understanding,i cleared the flag now i am suppose to go back to my normal routine(lets say main()). but it is not happening, it is coming back usage fault handler.

so now i have following questions

1. how to come out of exception? are there any other bits i am suppose to clear?

2. or once any exception comes, i cant go back to normal routine. only sw reset or POR will help me.

Thanks in advance...

#hardfault #stm32 #stm32f #fault-exception #m4
1 REPLY 1
Posted on February 10, 2016 at 15:02

What do you expect it to do when you return? Crash and fail somewhere else?

You can presumably dig into the stack, examine the faulting instruction, fix registers, advance the PC, pop up a level, or implement some throw/catch structured exception handler. All would require a significant appreciation of the problem, and the processor.

In the division by zero case, you really need to just fix your code so it identifies these issues before they fail, and you provide a valid exit strategy there to deal with it. In that sense it is better for the handler to output diagnostic info, and have you fix the bugs before releasing the code.

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