47.7.7 MCSPI Comparison Function on Received Character
The comparison is only relevant for MCSPI Client mode (MCSPI_MR.MSTR=0).
In Active mode, the Comparison Status (CMP) flag in MCSPI_SR is raised. It is set when the received character matches the conditions programmed in the MCSPI Comparison register (MCSPI_CMPR). The CMP flag is set as soon as MCSPI_RDR is loaded with the newly received character. The CMP flag is cleared by reading MCSPI_SR.
MCSPI_CMPR (see MCSPI_CMPR) can be programmed to provide different comparison methods. These are listed below:
- If VAL1 equals VAL2, then the comparison is performed on a single value and the flag is set to 1 if the received character equals VAL1.
- If VAL1 is strictly lower than VAL2, then any value between VAL1 and VAL2 sets the CMP flag.
- If VAL1 is strictly higher than VAL2, then the CMP flag is set to 1 if any received character equals VAL1 or VAL2.
When MCSPI_MR.CMPMODE is cleared, all received data is loaded in MCSPI_RDR and the CMP flag provides the status of the comparison result.
By setting MCSPI_MR.CMPMODE, the comparison result triggers the start of MCSPI_RDR loading (see the figure below). The trigger condition exists as soon as the received character value matches the conditions defined by VAL1 and VAL2 in MCSPI_CMPR. The comparison trigger event is restarted by setting MCSPI_CR.REQCLR .
The value programmed in the VAL1 and VAL2 fields must not exceed the maximum value of the received character (see MCSPI_CSR0.BITS).
