The signal monitoring unit has the
ability to measure pulse width (either low or high) or period (rise-to-rise edge or
fall-to-fall edge) and automatically generate an error when the pulse width is
outside of a programmable expected range.
The expected pulse width range is programmable using the following configuration
registers (or their respective shadow registers):
- MUNIT_#_MIN programs the minimum pulse width capture value
- MUNIT_#_MAX programs the
maximum pulse width capture value
Any pulse width outside of these
programmed bounds triggers one of two error events:
- MUNIT_#_ERROR_EVT1 generated
when measured pulse width is less than MUNIT_#_MIN
- MUNIT_#_ERROR_EVT2 generated
when measured pulse width is greater than MUNIT_#_MAX
The following diagram provides an
example in which the measured pulse width exceeds the MAX value, generating an
ERROR_EVT2 event.
Configuration Requirements
To enable this mode, the following settings must be configured:
- Absolute mode must be set for the ECAP counter, so that the counter is free
running and does not get reset on any capture events
- Continuous mode must be enabled
(one-shot mode can be used, but is not recommended given the short
duration)
- Sync feature for the counter must
be disabled (ECCTL2.SYNCI_EN = 0)
- A minimum of two captures must be
enabled (ECCTL2.STOP_WRAP >= 1, and at least CAP1 and CAP2 enabled)
- Capture Edge (ECCTL1.CAPxPOL) of
used capture modules (any of CAP1 to CAP4) must be configured to capture two
edges of interest
- High pulse: one rising
edge and one falling edge
- Low pulse: one rising
edge and one falling edge
- Period rise-to-rise: two
rising edges
- Period fall-to-fall: two
falling edges
Note: If a pulse width is greater than
the MAX value, a second edge can arrive late or never even occur. Because of this,
the DISABLE_EARLY_MAX_ERR field in the MUNIT_#_CTL register can be used to choose
when a MAX error occurs. By setting the bit to 0, an error is generated as soon as
the pulse width is greater than the specified maximum value. By setting the bit to
1, an error is generated when the second event has occurred.