7 PULSE_CNT
7. PULSE_CNT
7.1 Introduction
The pulse counter module is designed to count the number of rising and/or falling edges of an input signal. Each
pulse counter unit has a 16-bit signed counter register and two channels that can be configured to either
increment or decrement the counter. Each channel has a signal input that accepts signal edges to be detected,
as well as a control input that can be used to enable or disable the signal input. The inputs have optional filters
that can be used to discard unwanted glitches in the signal.
The pulse counter has eight independent units, referred to as PULSE_CNT_Un.
7.2 Functional Description
7.2.1 Architecture
Figure 16: PULSE_CNT Architecture
The architecture of a pulse counter unit is illustrated in Figure 16. Each unit has two channels: ch0 and ch1,
which are functionally equivalent. Each channel has a signal input as well as a control input which can both be
connected to I/O pads. The counting behaviour on both positive edge as well as negative edge can be
configured separately to increase, decrease or do nothing to the counter value. Separately, for both control signal
levels, the hardware can be configured to modify the edge action: invert it, disable it or do nothing. The counter
itself is a 16-bit signed up/down counter. Its value can be read by software directly, but is also monitored by a set
of comparators which can trigger an interrupt.
7.2.2 Counter Channel Inputs
As stated before, the two inputs of a channel can affect the pulse counter in various ways. The specifics of this
behaviour is set by LCTRL_MODE and HCTRL_MODE for the case when the control signal is low or high,
respectively, and POS_MODE and NEG_MODE for positive and negative edges of the input signal. Setting
POS_MODE and NEG_MODE to 1 will increase the counter when an edge is detected, setting them to 2 will
decrease the counter and setting any other value will make the edge not have any effect on the counter.
LCTR_MODE and HCTR_MODE modify this behaviour as such when the control input has the corresponding low
Espressif Systems
90
ESP32 Technical Reference Manual V1.0
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers