3.3.4.14 EMAFE_SetDifferenceComparisonMode Function

C

void EMAFE_SetDifferenceComparisonMode(EMAFE_DIFF_COMPARISON_DATA *data);

Summary

Set the comparison mode between two channels.

Description

The difference between two channels can be monitored on-the-fly and compared to a threshold to report an event in case the absolute value of the difference crosses the threshold.

The selection of channels is configured by writing the fields CHA_IDX and CHB_IDX in the LPFIF Comparison register (EMAFE_CDCR).

The threshold is configured writing the field EMAFE_CDCR.DIFFTHRES.

Only the 16 MSB of the filtered data are kept for the comparison. Therefore, a part of noise on selected channel is rejected by this truncation. EMAFE_CDCR.DIFFTYPE defines whether the event is triggered when the absolute value of the difference exceeds the configured threshold or when the absolute value of the difference is less than the threshold.

When the difference is above the threshold, the flag EMAFE_ISR.CHDIFF rises. The flag CHDIFF is cleared on read.

When the field EMAFE_CDCR.DIFFCOUNT differs from 0, the flag EMAFE_ISR.CHDIFF rises only when CHDIFF+1 consecutive different events occur.

Precondition

None.

Parameters

ParamDescription
dataPointer to the configuration values of the difference comparison mode.

Returns

None.

Example


EMAFE_DIFF_COMPARISON_DATA comparisonData;

comparisonData.channelA = EMAFE_COMP_CHN_2_ID;
comparisonData.channelB = EMAFE_COMP_CHN_4_ID;
comparisonData.diffThreshold = diffthresValue;
// Set Successive Comparison Event Count
comparisonData.diffCount = 5; 
// Absolute value of the difference between the first and second channels is greater than the threshold value
comparisonData.type = EMAFE_COMPARISON_HIGH; 

EMAFE_SetDifferenceComparisonMode(&comparisonData);

Remarks

Figure 3-24. Comparison of Two Channels