CAT2 Peripheral Driver Library
SysFault (System Fault)

The SysFault driver provides an API to configure the Fault reporting structure. More...

Modules

 Macros
 
 Enums
 
 Data Structures
 
 Functions
 

Detailed Description

The SysFault driver provides an API to configure the Fault reporting structure.

The functions and other declarations used in this driver are in cy_sysfault.h. You can include cy_pdl.h to get access to all functions and declarations in the PDL. This driver is only available for PSOC 4 HVMS 64/128K, PSOC 4 HVPA 144K, and PAG2S devices.

The fault subsystem contains information about faults that occur in the system. The fault subsystem captures only faults and does not take any action to correct them. The subsystem can cause a reset, give a pulse indication, or trigger another peripheral. HVMS 64/128K, PSOC 4 HVPA 144K, and PAG2S devices use a centralized fault report structure. The centralized nature allows for a system-wide consistent handling of faults, which simplifies software development. Only a single fault interrupt handler is required. The fault report structure provides the fault source and additional fault-specific information from a single set of memory mapped input/output (MMIO) registers, no iterative search is required for the fault source and fault information. All pending faults are available from a single set of MMIO registers. Below is the block diagram.

fault.png

The Fault IP provides a fault report structure. The fault report structures capture faults. The number of fault report structures is specified by the design time configuration parameter (FAULT_NR). In CAT2, there are two instances of fault structures, each fault report structure has a dedicated set of MMIO control and status registers and captures a single fault. The fault report structure provides fault source and additional fault specific information from a single set of MMIO registers. The fault structures capture faults like peripheral specific errors, memory controller specific errors. E.g., SRAM controller ECC errors, FLASH controller read during program and ECC errors, time out errors, power errors.

Note
Note that some of the above faults also result in errors on the bus infrastructure.

System fault will be captured by fault report structures. A fault report structure provides the fault source and additional fault specific information from a single set of MMIO registers. The captured fault information includes:

Note
When a fault is configured to trigger a reset, the debugging of the configured fault structure is not possible.
Warning
The ROM boot uses fault structure #0 (FAULT_STRUCT0) to detect potential fault sources during boot. It sets up fault masks to detect not correctable ECC errors for SRAM and flash. If fault report structure #0 is used to capture faults and is configured to trigger a reset, use the weak Cy_BootStatus() function and Cy_SysLib_GetBootStatus() ~~should be used~~ to handle Boot-Up Status. Applicable to PSOC4 HVMS/PA only.

Configuration Considerations

Fault configuration includes the clearing of the existing fault status, enabling the fault source, setting an interrupt mask, and fault initialization. Below is the code snippet for the fault configuration.

/* Scenario: Configures the SysFault for recording faults. */
/* SysFault interrupt priority */
#define SYSFAULT_INTR_PRIORITY (2UL)
#define SYSFAULT_INTR_NUM ((IRQn_Type) cpuss_interrupt_fault_0_IRQn)
/* SysFault config */
cy_stc_sysfault_config_t sysfaultConfig =
{
.resetEnable = false,
.outputEnable = true,
.triggerEnable = false,
};
/* Configure Interrupt for SysFault structure */
cy_stc_sysint_t sysfaultIntrConfig =
{
.intrSrc = SYSFAULT_INTR_NUM,
.intrPriority = SYSFAULT_INTR_PRIORITY
};
/*********************************************************************/
/***** Fault report settings *****/
/*********************************************************************/
Cy_SysFault_ClearStatus(FAULT_STRUCT0); // clear status
Cy_SysFault_SetMaskByIdx(FAULT_STRUCT0, SRSS_FAULT_CRWDT); // enable Fault CRWDT
cy_en_sysfault_status_t status = Cy_SysFault_Init(FAULT_STRUCT0, &sysfaultConfig);
/*********************************************************************/
/***** Interrupt settings *****/
/*********************************************************************/
(void) Cy_SysInt_Init(&sysfaultIntrConfig, &irqFaultHandler);
NVIC_EnableIRQ(SYSFAULT_INTR_NUM);
/* Triggers an interrupt via a software write.*/
Cy_SysFault_SetInterrupt(FAULT_STRUCT0);

Once a configured fault occurs, the interrupt handler will be triggered where the fault information can be captured. Below is the code snippet, which can be part of the interrupt handler.

/* Scenario: Handle the faults generated and get the fault data. */
/* Returns the status of the interrupt for the fault structure */
uint32_t intrStatus = Cy_SysFault_GetInterruptStatus(FAULT_STRUCT0);
/* Returns the interrupt mask. */
uint32_t intrMask = Cy_SysFault_GetInterruptMask(FAULT_STRUCT0);
/* Returns whether masked interrupt and triggered the interrupt are same. */
uint32_t intrMskdStatus = Cy_SysFault_GetInterruptStatusMasked(FAULT_STRUCT0);
cy_en_sysfault_source_t sysfaultSource = Cy_SysFault_GetErrorSource(FAULT_STRUCT0);
if(sysfaultSource != CY_SYSFAULT_NO_FAULT)
{
if(sysfaultSource == SRSS_FAULT_CRWDT) // CRWDT Fault
{
Cy_SysFault_GetFaultData(FAULT_STRUCT0, CY_SYSFAULT_DATA0); // get fault data
}
}
/* Clears an interrupt mask.*/
/* Clear Interrupt flag */

More Information

For more information on the System Fault, refer to the technical reference manual (TRM).

Changelog

VersionChangesReason for Change
1.0 Initial version