28.3.7 Decoder
Many applications, such as quadrature decoding, require some sort of processing of the sensor readings. In quadrature decoding, the
sensors repeatedly pass through a set of states which correspond to the position of the sensors. This sequence, and many other de-
coding schemes, can be described as a finite state machine. To support this type of decoding without CPU intervention, the LESENSE
module includes a highly configurable decoder capable of decoding input from up to four sensors. The decoder is implemented as a
programmable state machine with up to 32 states. When doing a sensor scan, the results from the sensors are placed in the decoder
input register, SENSORSTATE, if DECODE in CHx_INTERACT is set. The resulting position after a scan is illustrated in
28.10 Sensor Scan and Decode Sequence on page 941
, where the bottom blocks show how the SENSORSTATE register is filled. If
step detection is enabled, the step direction is placed in SENSORSTATE in the position after the sensor result. When the scan se-
quence is complete, the decoder evaluates the state of the sensors chosen for decoding, as depicted in
CH0
CH1
START
START
Scan period
Decode
CH2
CH3
CH0
CH1
Decode
CH2
CH3
CH0
result
-
-
-
CH0
result
CH1
result
-
-
CH0
result
CH1
result
CH2
result
-
CH0
result
CH1
result
CH2
result
CH3
result
SENSORSTATE[0]
SENSORSTATE[3]
CH0
result
CH1
result
CH2
result
CH3
result
CH0
result
CH1
result
CH2
result
CH3
result
CH0
result
CH1
result
CH2
result
CH3
result
CH0
result
CH1
result
CH2
result
CH3
result
Figure 28.10. Sensor Scan and Decode Sequence
Upon a state transition, LESENSE can generate a pulse on one or more of the decoder PRS channels. Which PRS channel to generate
a pulse on is configured in the PRSACT bit field. If PRSCNT in DECCTRL is set, count signals will be generated on decoder PRS chan-
nels 0 and 1 according to the PRSACT configuration. In this mode, channel 0 will pulse each time a count event occurs, while channel 1
indicates the count direction (1 being up and 0 being down). The count direction will be kept at its previous state in between count
events. The EFR32 pulse counter may be used to keep track of events based on these PRS outputs.
If SETIF is set, the DECODER interrupt flag will be set when the transition occurs. If INTMAP in DECCTRL and SETIF is set, a transi-
tion from state x or x+16 will set the CHx interrupt flag in addition to the DECODER flag.
Setting CHAIN in STx_TCONFA enables the decoder to evaluate more than two possible transitions for each state. If none of the transi-
tions defined in STx_TCONFA or STx_TCONFB match, the decoder will jump to the next descriptor pair and evaluate the transitions
defined there. The decoder uses two LFACLK
LESENSE
cycles for each descriptor pair to be evaluated. If ERRCHK in CTRL is set, the
decoder will check that the sensor state has not changed if none of the defined transitions match. The DECERR interrupt flag will be set
if none of the transitions match and the sensor state has changed.
Figure 28.11 Decoder State Transition Evaluation on page 942
illustrates state transitions. The "Generate PRS signals and set interrupt flag" blocks will perform actions according to the configuration
in STx_TCONFA and STx_TCONFB.
Note:
If only one transition from a state is used, STx_TCONFA and STx_TCONFB should be configured equally.
Reference Manual
LESENSE - Low Energy Sensor Interface
silabs.com
| Building a more connected world.
Rev. 1.1 | 941