cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfault_Handler() with minimum new project

Stoufer
Associate III

Hi - I am new to the STM32CubeIDE - moving from Attolic.

I have created a new STM32 project using STM32CubeIDE 1.9.0 for a STM32L151VET6 using New Project.

Our board is built to use an internal oscillator. 

I can try to debug the basically empty new created project or add just a for loop in the while(1) in main() and either way it immediately stops on Hardfault_Handler. 

In the Fault Analyzer :

X Bus, memory management or usage fault (FORCED)

X Imprecise data access violation (IMPRECISER)

X Stacking error (STKERR)

I have set a breakpoint on the while(1) and on the for loop inside it and neither are ever hit.

I believe I have set the pins in the IOC to match my board ( UART, SPI, GPIO )

Any suggestions on how to proceed ?

Thanks!

11 REPLIES 11
Stoufer
Associate III

Thanks!!

I found it right away looking at the startup files. Realized the board I am using has a STM32L151V C T6, and I had selected a V E T6 because that is on another board on my desk - we use both in production.

Thanks for you guys help !

Thank you so much for posting your solution. I was fighting with my (first) custom board for the same reason you're describing: no code was executing at all, seemed to crash before break points even trigger, and looking in the SFRs (while debugging, upper right hand corner) under Cortex M4 -> Control -> CFSR I was seeing both STKERR and IMPRECISERR set.

Turns out, I wrote my code originally on a Nucleo featuring the STM32F401R E T6, but my board uses the STM32F401R C T6. I made a new project with the correct chip and it immediately worked. Thanks again!