MTB CAT1 Peripheral driver library
SysFault (System Fault)

General 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 CAT1C, CAT1D devices.

The Fault subsystem contains information about faults that occur in the system. The fault subsystem captures only faults and it does not take any action to correct it. The subsystem can cause a reset, give a pulse indication, or trigger another peripheral. CAT1C, CAT1D uses a centralized fault report structure. The centralized nature allows for a system-wide consistent handling of faults, which simplifies software development as follows 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

Fault IP provides fault report structure. Fault report structures capture faults. The number of fault report structures is specified by a design time configuration parameter (FAULT_NR). In CAT1C, CAT1D 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. A fault report structure provides the fault source and additional fault specific information from a single set of MMIO registers. The fault structures capture faults like MPU/SMPU/PPI protection violations, peripheral specific errors, memory controller specific errors. E.g., SRAM controller ECC errors, FLASH controller read while program and ECC errors, Processor tightly coupled memory (TCM) ECC errors.

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:

Configuration Considerations

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

/* Scenario: Configures the SysFault for recording faults. */
/* Fault config */
{
.ResetEnable = false,
.OutputEnable = true,
.TriggerEnable = false,
};
/* Configure Interrupt for Fault structure */
cy_stc_sysint_t IRQ_cfg =
{
.intrSrc = ((NvicMux3_IRQn << CY_SYSINT_INTRSRC_MUXIRQ_SHIFT) | cpuss_interrupts_fault_0_IRQn), /* Bit 0-15 of intrSrc is used to store system interrupt value and bit 16-31 to store CPU IRQ value */
.intrPriority = 2UL
};
/*********************************************************************/
/***** Fault report settings *****/
/*********************************************************************/
Cy_SysFault_ClearStatus(FAULT_STRUCT0); // clear status
Cy_SysFault_SetMaskByIdx(FAULT_STRUCT0, CY_SYSFAULT_SRSS_MCWDT0); // enable Fault MCWDT #0
cy_en_SysFault_status_t status = Cy_SysFault_Init(FAULT_STRUCT0, &config);
/*********************************************************************/
/***** Interrupt settings *****/
/*********************************************************************/
Cy_SysInt_Init(&IRQ_cfg, &irqFaultHandler);
NVIC_SetPriority((IRQn_Type) NvicMux3_IRQn, 2UL);
NVIC_EnableIRQ((IRQn_Type) NvicMux3_IRQn);
/* Triggers an interrupt via a software write.*/
Cy_SysFault_SetInterrupt(FAULT_STRUCT0);

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

/* Scenario: Handle the faults generated and get the fault data. */
/* Returns the status of the interrupt for the fault structure */
uint32_t intrSource = Cy_SysFault_GetInterruptStatus(FAULT_STRUCT0);
/* Returns the interrupt mask. */
uint32_t intrMskStatus =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 status = Cy_SysFault_GetErrorSource(FAULT_STRUCT0);
if(status != CY_SYSFAULT_NO_FAULT)
{
if(status == CY_SYSFAULT_SRSS_MCWDT0) // MCWDT0 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.30 Added enum en_sysfault_source_t and new macros. Support added for CAT1D and enabled sysfault compilation for PSoC C3 (CAT1B).
1.20 Updated Cy_SysFault_GetErrorSource API and added new macro MISRA 10.8 fix and code enhancement
1.10 Updated macro related to driver enablement for CAT1C without any functional impact Code Enhancement
1.0 Initial version

API Reference

 Macros
 
 Enums
 
 Data Structures
 
 Functions