49.7.5 SPI Comparison Function on Received Character

The comparison is only relevant for SPI Client mode (SPI_MR.MSTR=0).

The effect of a comparison match changes if the system is in ULP1 or Active mode.

In ULP1 mode, if asynchronous partial wake-up is enabled, a system wake-up is performed (see section SPI Asynchronous and Partial Wake-up).

In Active mode, the CMP flag in SPI_SR is raised. It is set when the received character matches the conditions programmed in the SPI Comparison egister (SPI_CMPR). The CMP flag is set as soon as SPI_RDR is loaded with the new received character. The CMP flag is cleared by reading SPI_SR.

SPI_CMPR (see section SPI Comparison Register) 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 flag CMP is set to 1 if any received character equals VAL1 or VAL2.

When SPI_MR.CMPMODE is cleared, all received data is loaded in SPI_RDR and the CMP flag provides the status of the comparison result.

By setting SPI_MR.CMPMODE, the comparison result triggers the start of SPI_RDR loading (see the following figure). The trigger condition exists as soon as the received character value matches the conditions defined by VAL1 and VAL2 in SPI_CMPR. The comparison trigger event is restarted by setting SPI_CR.REQCLR if asynchronous partial wake-up is disabled.

The value programmed in VAL1 and VAL2 fields must not exceed the maximum value of the received character (see SPI_CSR0.BITS).

Figure 49-13. Receive Data Register Management