HardFault Handler, from where jumped to here ?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ipek
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked
Hi,

My software starts crashing after I add spi configure code. I wasn't using exception handlers before. Now I added them and saw that program jumps to HardFault Handler
I want to understand why this is happening but I couldn't find what causes this.. I checked ARM Cortex M0 documentation. I saw that Main Stack Pointer(this is the SP my code normally uses) can be used to track down the
PC before exception. But it shows a meaningless value (0x75300) there is nothing in there..

More about my code
There is a simple scheduler I created, It runs tasks in a while(1).
These tasks sends CAN messages and receives can interrupts.
There is a tick publishers. Publishes tick interrupts in every 20 msec( SysTick_Handler is used)
This whole thing was working just perfect. Then I add SPI configure code. ( which I write by taking DAVE APPs generated code as referance)
After that, it start to shoot exceptions before even first tick. I suspect that this exception occurs with the first tick interrupt..
There is another interesting thing.. If I didn't enable CAN receive interrupt whole thing works just fine too!
So for now exception only occurs if SPI is configured && CAN receive interrupt is enabled.
I attached the Debug Panel Screenshot too..
I keep digging but wanted to ask in here too. Maybe someone may help to speed up this process.. Because I have a timeline and have to fix this in 2 days.
Thanks in advance,
İpek
0 Likes
1 Reply
ipek
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked
Hi pals,

I solved it!
That SPI stuff is causing stack overflow. And the address of SysTick_Handler that is going to be used to branch when tick interrupt occurred gets corrupted.
I increased the stack size from linker script and problem solved
0 Likes