cancel
Showing results for 
Search instead for 
Did you mean: 

Hard_fault Handler error

mohit rai
Associate II
Posted on December 09, 2017 at 12:37

Hello,

I am using STM32f4 discovery board. On this board, I am using 2 timer interrupt(TIM2 & TIM3) and 1 external interrupt(External interrupt for reading data from the external board).TIM2 is generating an interrupt after 1 second and TIM2 after 125 microseconds.

When I run my code enable all interrupts. it gets stuck in the hard fault handler.

I have tried by changing the interrupt time and priority both.

When I enable only two interrupts, my code is working properly.

enable only tim2 and external interrupt...it is working.

enable only tim3 and external interrupt ...it is working.

enable only tim2 and tim3 ...it is working.

What can be the cause of Hard fault handler?

Thanks in advance.

Regards,

Mohit Rai
3 REPLIES 3
mohit rai
Associate II
Posted on December 09, 2017 at 13:11

Got the solution. My external interrupt handler processing time was more. I have written a number of line in the handler. due to this reason, my code my not working when I was enabling all the interrupt.

Problem solved.

Posted on December 09, 2017 at 13:15

Having the handler identify the faulting instruction will also help.

https://community.st.com/0D50X00009Xke40SAB

My guess would have been a division by zero, or insufficient stack depth

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on December 09, 2017 at 20:42

Hello,

Thank you for your response.

In cortex M4, for divide by zero.I have to configure Configuration and Control Register (CCR).

and I have not configured this register. this problem may be due to insufficient stack depth.

I will check my code.

Regards,

Mohit Rai