cancel
Showing results for 
Search instead for 
Did you mean: 

Hard Fault Handler Interrupt Stm32F1?

danielblesener9
Associate II
Posted on January 02, 2013 at 21:55

Any help with finding this bug is appreciated. I am truly at a loss.

I am using the virtual com port for USB(V.3.1). I had it working great, communication was like a wife and husband once wished. I was sending host data through pre-assembled arrays and sending characters 1 by 1 by USART_To_USB_Send_Data function. Now I do the same the but use _io_putchar() along with printf(), so I have added #include <stdio> and a few functions.

Of course, I simple change suddenly caused a hard fault error? I have never dealt with these before and am not sure what to do with it. In comparing code, I cannot find any problems, looking through the reference and programming manual has not helped. 

After the fault occurs, the debug explore shows the following info:

HFSR       = 0x04000000

VECTTBL    = NO FAULT

FORCED      = SET

DEBUGEVT = NO Fault Related to Debug

Thanks much.

1 REPLY 1
Posted on January 02, 2013 at 22:42

You need to look at the faulting instructions. How printf() works will depend on your tool chain, you don't mention which. If you haven't got Keil set up properly wrt to semi-hosting you'll get an SWI instruction faulting the processor.

A decent fault handler should point you in the right direction.

https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32VLDiscovery/DispForm.aspx?ID=672&RootFolder=/public/STe2ecommunities/mcu/Lists/STM32VLDiscovery/stack%20problem%20and%20privilege%20mode

This one might be a bit of a catch-22 as you don't have a functional printf(), you want to be locating the PC of the faulting code, you can dig through the stack.

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