Showing results for 
Search instead for 
Did you mean: 

Getting Hard Fault Exception at -40c while using STM32F0412VET


I'm getting Hard Fault Exception at -40c while using STM32F0412VET. Any idea how to avoid such exception ? setting certain registers or disabling certain peripherals?

As well is there sample implementation to return to previous context before the exception?



Ireen Abdelmalak


Expand the wait states on the FLASH, reduce speed? Not much detail to work with here.

Hard Fault Handler can return, you'd be expected to unpack the MCU state and resolve, or advance. Would suggest reading the Technical Reference Manual for the Cortex-M0

Perhaps start by dumping the failure context to understand what's actually going wrong.

Might be easier to implement a try/catch structured exception handler method..

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

You try to "study" the effect of very low temperatures (in space) on silicon (chips, MCUs).

If you run outside the spec. - assume "everything can happen".

A HardFault_Handler called is usually an indication that the code instructions tried to access "wrong memory". In your case, it could be also that the instruction was wrong (doing something wrong, getting an address wrong).

Avoid such one: "do not have bugs in your SW/FW".

Disabling: it does not make sense to "hide" serious issue with the code.

How to recover: going back to the code, which is corrupted or has a bug, does not make sense.
You could reset the chip, in HardFault_Handler, and start over. But it the low temperature causes the issue - you end up there again.

BTW: you cannot disable this HardFault_Handler: it is a non-maskable interrupt (like Reset_Handler and some other).

A HardFault_Handler called is very serious and tells you "there is fundamentally really wrong". If your code is going wrong on low temperatures (because the internal flash gives wrong bits) - do not run with such a low temperature.

If all works fine on normal temperature, but it fails if you put the board into liquid nitrogen - even the chip (dye) can crack and internal silicon can break.