Digital Power Starter Kit 3 Firmware
dsPIC33C Buck Converter Voltage Mode Control Example

Public functions of the fault handler library layer. More...

+ Collaboration diagram for Public Functions:

Functions

volatile uint16_t drv_FaultHandler_CheckObject (volatile struct FAULT_OBJECT_s *fltObject)
 Check current fault status of a user-defined fault object. More...
 
volatile uint16_t drv_TrapHandler_SoftTrapsInitialize (bool accumulator_a_overflow_trap_enable, bool accumulator_b_overflow_trap_enable, bool accumulator_catastrophic_overflow_trap_enable)
 Configures the software-configurable traps. More...
 
void DefaultTrapHandler (enum TRAP_ID_e trap_id)
 Centralized trap handler routine. More...
 

Detailed Description

Public functions of the fault handler library layer.

This is the detailed description of public functions of the fault handler library.

Function Documentation

◆ DefaultTrapHandler()

void DefaultTrapHandler ( enum TRAP_ID_e  trap_id)

Centralized trap handler routine.

This routine is used as centralized trap handler for all traps. Each trap is identified and logged by a unique trap ID and the status bits of traps and interrupt vectors are captured

Users may modify the basic framework provided here to suit to the needs of their application.

Definition at line 116 of file drv_trap_handler.c.

◆ drv_FaultHandler_CheckObject()

uint16_t drv_FaultHandler_CheckObject ( volatile struct FAULT_OBJECT_s fltObject)

Check current fault status of a user-defined fault object.

Parameters
fltObjectPointer to a Fault Monitoring Object of type struct FAULT_OBJECT_s
Returns
unsigned integer (0=failure, 1=success)

This routine compares the most recent value of a global variable or SFR (SOURCE) against user-defined thresholds. If the value violates/exceeds one or more of the user defined conditions, a fault counter is incremented.

When this fault counter exceeds the user-defined maximum, a fault condition is tripped and the fault_status flag bit is set.

When a fault condition has been tripped and the fault status is set (=true), the fault check monitors for the source value triggering a recovery event. The recovery process works like the fault trip event by comparing the most recent source value against the user-defined RECOVERY_LEVEL. Once the value has been RSTCNT_MAX times below the RECOVERY_LEVEL threshold, the fault will automatically be cleared.

a) Comparison Types

The fault handler offers the following different comparison methods:

  • Greater Than:
    • performs comparison SOURCE > TRIP_LEVEL
    • TRIP_LEVEL is greater than RECOVERY_LEVEL. The difference between TRIP_LEVEL and RECOVERY_LEVEL is the hysteresis of the defined threshold.
  • Less Than:
    • performs comparison SOURCE < TRIP_LEVEL
    • TRIP_LEVEL is less than RECOVERY_LEVEL. The difference between TRIP_LEVEL and RECOVERY_LEVEL is the hysteresis of the defined threshold.
  • Is Equal:
    • performs comparison SOURCE == TRIP_LEVEL
    • RECOVERY_LEVEL is ignored.
  • Is Not Equal:
    • performs comparison SOURCE != TRIP_LEVEL
    • RECOVERY_LEVEL is ignored.
  • Between:
    • performs comparison RECOVERY_LEVEL < SOURCE < TRIP_LEVEL
    • min/max of the FAULT range is defined by the range between RECOVERY_LEVEL (min) and TRIP_LEVEL (max)
  • Outside:
    • performs comparison (SOURCE < RECOVERY_LEVEL) or (TRIP_LEVEL < SOURCE)
    • min/max of the allowed operating range is defined by the range between RECOVERY_LEVEL (min) and TRIP_LEVEL (max)

b) Value Filtering

A bit-mask filter can be used to monitor individual register bits or filter on specific bits within a 16-bit wide value. The bit-mask is always applied the source value. If no bit-mask is required, set bitmask = 0xFFFF;

c) Comparison of two dynamic values

When dynamic values of two variables need to be compared, the fault object offers a second pointer to a so-called reference object "ref_obj". When this pointer is != NULL, the absolute value of the difference between SOURCE and REFERNCE is compared against the user-defined TRIP and RECOVERY thresholds. When no second value is used, set ref_obj = NULL (NULL-pointer). This will force the fault check to ignore this value.

d) User defined responses

Function pointers "trip_response" and "reset_response" can be used to assign user-defined functions which should be called when a fault condition has been tripped or reset. I no user-defined function should be called, these pointers can be set = NULL (NULL-pointer)

Note
If the value is within normal operating conditions, the fault counter will be cleared. Thus fault events must occur successively incrementing the fault event counter high enough to eventually trip a fault event. Thus the fault event counter can be used to adjust the sensitivity of the fault response.

Definition at line 168 of file drv_fault_handler.c.

◆ drv_TrapHandler_SoftTrapsInitialize()

uint16_t drv_TrapHandler_SoftTrapsInitialize ( bool  accumulator_a_overflow_trap_enable,
bool  accumulator_b_overflow_trap_enable,
bool  accumulator_catastrophic_overflow_trap_enable 
)

Configures the software-configurable traps.

Parameters
accumulator_a_overflow_trap_enableFlag of type Boolean enabling/disabling accumulator A trap at 1.31 overflow
accumulator_b_overflow_trap_enableFlag of type Boolean enabling/disabling accumulator B trap at 1.31 overflow
accumulator_catastrophic_overflow_trap_enableFlag of type Boolean enabling/disabling catastrophic accumulator trap at 9.31 overflow

This routine sets the DSP-specific traps for overflow-events of accumulator A and B.

Definition at line 90 of file drv_trap_handler.c.