Hard Fault Interrupt Handler Function – KBA86934

Version: **


Question: How can you write a hard fault interrupt handler function using the default interrupt handler for your PSoC® 5LP project?



Hard fault is an always-enabled exception that occurs because of an error during normal or exception processing. Hard fault has a fixed priority of ‘–1’, meaning it has higher priority than any exception with configurable priority. The interrupt number given for the hard fault interrupt in the PSoC 4 and PSoC 5LP exception table is ‘3’.

The API CyIntSetSysVector() is used for setting interrupt vectors for the system interrupt with the specified number. HFI_Handler is the name of the user defined ISR routine for a hard fault exception. The C code for the hard fault ISR routine can be written by adding the code shown below into your main.c file:

CyIntSetSysVector(3,HFI_Handler); //add this statement to your main( )

Now you can write your own ISR in the main.c file as shown below:

CY_ISR(HFI_Handler){//Your code here}