ModusToolbox Safety Test Library
Loading...
Searching...
No Matches

General Description

Functions

uint8_t SelfTests_Opamp (SAR_Type *sar_base, int16_t expected_res, int16_t accuracy, uint32_t opamp_in_channel, bool count_to_mV)
 Performs OPAMP test and verifies if the measured voltage is in the accuracy range.
uint8_t SelfTests_ADC_TrigIn (uint32_t group, uint32_t channel, int32_t expected_res, int32_t accuracy, uint32_t trig_in)
 Performs an ADC self-test by issuing a firmware SAR trigger and verifying that the measured result falls within the expected range.
uint8_t SelfTests_ADC (SAR_Type *base, uint32_t channel, int16_t expected_res, int16_t accuracy, uint32_t vbg_channel, bool count_to_mV)
 Performs ADC test and verifies if the measured voltage is in the accuracy range.
uint8_t SelfTests_Comparator (LPCOMP_Type const *lpcomp_base, cy_en_lpcomp_channel_t lpcomp_channel, uint8_t expected_res)
 Performs Comparator test and verifies if the higher voltage on +ve terminal compared to -ve terminal generates a high output and vice verse.
uint8_t SelfTests_DAC (CTDAC_Type *dacBase, SAR_Type *adcBase, uint32_t adcChannel)
 Performs DAC test and verifies that the input of DAC and output from ADC are the same.
uint8_t SelfTests_DAC_TrigIn (uint32_t adc_channel, uint32_t dac_slice, uint32_t dac_val, int16_t expected_res, int16_t accuracy, uint32_t adc_trig_in, uint32_t dac_trig_in)
 Performs DAC test and verifies that the input of DAC and output from ADC are the same.

Function Documentation

◆ SelfTests_Opamp()

uint8_t SelfTests_Opamp ( SAR_Type * sar_base,
int16_t expected_res,
int16_t accuracy,
uint32_t opamp_in_channel,
bool count_to_mV )

Performs OPAMP test and verifies if the measured voltage is in the accuracy range.

Parameters
sar_baseThe pointer to a SAR ADC instance.
expected_resIf count_to_mV = 1 => Expected result in mV, else Expected result in counts.
accuracyAccuracy in count ANALOG_OPAMP_ACCURACY
opamp_in_channelChannel number where the OPAMP output is read.
count_to_mV1 = convert the count to mV.(take more time)
Returns
OK_STATUS (0) - Test passed
ERROR_STATUS (1) - Test failed

◆ SelfTests_ADC_TrigIn()

uint8_t SelfTests_ADC_TrigIn ( uint32_t group,
uint32_t channel,
int32_t expected_res,
int32_t accuracy,
uint32_t trig_in )

Performs an ADC self-test by issuing a firmware SAR trigger and verifying that the measured result falls within the expected range.

HPPASS subsystem configuration and signal routing:
The test uses the CSG VDAC (pass[0].csg[0].slice[0]) as an internally generated stimulus so that no external reference voltage is required on any device pin. The complete analog signal path through the HPPASS block is:

CSG Group 0, Slice 0 (VDAC, buffered, 10-bit) → CSG analog router (dacOutSelLoc = 1) → SAR muxed sampler input → SAR channel CSG_VDAC_OUT_CHAN_IDX (defined in cycfg_peripherals.h)

The following HPPASS configurations are required:

  • CSG[0]: Group 0 power enabled (grpPwrEn0 = true), CSG AROUTE mux not used (arouteMuxSel0 = CY_HPPASS_CSG_AROUTE_NONE), DAC output location 1 (dacOutSelLoc = 1, routes the VDAC output to the HPPASS analog router so the SAR muxed sampler can reach it).
  • CSG[0] Slice 0: mode = CY_HPPASS_DAC_MODE_BUFFERED (10-bit VDAC with output buffer).
  • HPPASS input trigger 2 (pass[0].input_trigger[2]): CY_HPPASS_TR_FW_PULSE — used to fire the SAR sequencer group that samples the DAC output (passed as trig_in = CY_HPPASS_TRIG_2_MSK).
  • SAR[0]: Vref = CY_HPPASS_SAR_VREF_VDDA, 12-bit result, right-aligned, unsigned. Muxed sampler 0 (pass[0].sar[0].muxed_sampler[0]) connected to the CSG VDAC analog router output.
  • SAR[0] sequencer group (pass[0].sar[0].seq[0].grp[N]): muxed sampler 0 enabled (muxSampEn0 = true), mux input select pointing to the CSG VDAC output, trigger = CY_HPPASS_SAR_TRIG_2 (corresponding to trig_in). The result is stored in SAR channel CSG_VDAC_OUT_CHAN_IDX.
  • Autonomous Controller (pass[0].ac[0]): the HPPASS AC must be started (Cy_HPPASS_AC_Start()) before any SAR conversion can be triggered. The AC Finite State Automaton (FSA) must be configured with at least one state (pass[0].ac[0].stt[0].vstate[0]) that keeps the subsystem running, e.g. action = CY_HPPASS_ACTION_STOP with count = 1. The AC holds the HPPASS clock and power rails active; without it the SAR trigger is ignored.

The caller must pre-stage the DAC stimulus before calling this function: program the desired 10-bit code with Cy_HPPASS_DAC_SetValue(), start the DAC slice with Cy_HPPASS_DAC_Start() in HW mode, and wait for the DAC to settle before invoking SelfTests_ADC_TrigIn(). This function then issues the SAR trigger specified by trig_in and reads the conversion result from channel.

Parameters
groupSAR group instance (0 for SAR[0]).
channelSAR channel index where the DAC stimulus is sampled. Use the macro CSG_VDAC_OUT_CHAN_IDX generated in cycfg_peripherals.h for the target BSP.
expected_resExpected ADC result in counts (12-bit, Vref = VDDA).
accuracyAcceptable deviation from expected_res in counts (ANALOG_ADC_ACCURACY).
trig_inHPPASS input trigger mask that fires the SAR sequencer group containing the muxed sampler channel (e.g. CY_HPPASS_TRIG_2_MSK).
Returns
OK_STATUS (0) - Test passed
ERROR_STATUS (1) - Test failed

◆ SelfTests_ADC()

uint8_t SelfTests_ADC ( SAR_Type * base,
uint32_t channel,
int16_t expected_res,
int16_t accuracy,
uint32_t vbg_channel,
bool count_to_mV )

Performs ADC test and verifies if the measured voltage is in the accuracy range.

Parameters
baseThe pointer to a SAR ADC instance. For PSOC Control C3 devices, the base is the group instance.
channelThe channel number where the input voltage needs to be read.
expected_resIf count_to_mV = 1, then the expected result in mV, else expected result in counts
accuracyAccuracy in count ANALOG_ADC_ACCURACY
vbg_channelThe channel number where the VBG voltage is connected. Only for XMC7000 and XMC5000 devices.
count_to_mV1 = convert the count to mV.(take more time). Not applicable for PSOC Control C3 devices.
Returns
OK_STATUS (0) - Test passed
ERROR_STATUS (1) - Test failed
Note
For CA1B devices, the user needs to configure the trigger input the same as the channel number.

◆ SelfTests_Comparator()

uint8_t SelfTests_Comparator ( LPCOMP_Type const * lpcomp_base,
cy_en_lpcomp_channel_t lpcomp_channel,
uint8_t expected_res )

Performs Comparator test and verifies if the higher voltage on +ve terminal compared to -ve terminal generates a high output and vice verse.

Parameters
lpcomp_baseThe pointer to a Comparator instance
lpcomp_channelConfigured channel number
expected_resExpected result (1 or 0)
Returns
OK_STATUS (0) - Test passed
ERROR_STATUS (1) - Test failed

◆ SelfTests_DAC()

uint8_t SelfTests_DAC ( CTDAC_Type * dacBase,
SAR_Type * adcBase,
uint32_t adcChannel )

Performs DAC test and verifies that the input of DAC and output from ADC are the same.

The digital input value to DAC maps to 1.5V

Parameters
dacBaseThe pointer to a DAC instance.
adcBaseThe pointer to a SAR ADC instance.
adcChannelThe channel number of SAR ADC instance.
Returns
OK_STATUS (0) - Test passed
ERROR_STATUS (1) - Test failed
Note
Applicable only to PSOC 61 Programmable Line and PSOC 62 Performance Line devices.

◆ SelfTests_DAC_TrigIn()

uint8_t SelfTests_DAC_TrigIn ( uint32_t adc_channel,
uint32_t dac_slice,
uint32_t dac_val,
int16_t expected_res,
int16_t accuracy,
uint32_t adc_trig_in,
uint32_t dac_trig_in )

Performs DAC test and verifies that the input of DAC and output from ADC are the same.

Parameters
adc_channelThe pointer to the ADC channel.
dac_sliceThe pointer to DAC slice.
dac_valThe value to be loaded into DAC register.
expected_resChannel expected result in ADC.
accuracyError tolerance.
adc_trig_inADC trigger input.
dac_trig_inDAC trigger input.
Returns
OK_STATUS (0) - Test passed
ERROR_STATUS (1) - Test failed
Note
Applicable only to PSOC Control C3 devices.