summaryrefslogtreecommitdiff
path: root/docs/esp32
diff options
context:
space:
mode:
authorJonathan Hogg <me@jonathanhogg.com>2022-09-10 17:08:27 +0100
committerDamien George <damien@micropython.org>2025-08-01 23:45:18 +1000
commite54553c496bf915ed0263c2d2a61d31d61032dea (patch)
treede218b3dea72fbfa071a09d49c292b765e3bbd17 /docs/esp32
parentc3f3339c87444acec814a150fdad28e650483405 (diff)
docs/esp32: Add documentation for esp32.PCNT.
Document the new `esp32.PCNT` class for hardware pulse counting. Originally authored by: Jonathan Hogg <me@jonathanhogg.com> Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'docs/esp32')
-rw-r--r--docs/esp32/quickref.rst21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/esp32/quickref.rst b/docs/esp32/quickref.rst
index 49f546a17..7127cc402 100644
--- a/docs/esp32/quickref.rst
+++ b/docs/esp32/quickref.rst
@@ -566,6 +566,27 @@ ESP32 S2:
Provided to deinit the adc driver.
+Pulse Counter (pin pulse/edge counting)
+---------------------------------------
+
+The ESP32 provides up to 8 pulse counter peripherals depending on the hardware,
+with id 0..7. These can be configured to count rising and/or falling edges on
+any input pin.
+
+Use the :ref:`esp32.PCNT <esp32.PCNT>` class::
+
+ from machine import Pin
+ from esp32 import PCNT
+
+ counter = PCNT(0, pin=Pin(2), rising=PCNT.INCREMENT) # create counter
+ counter.start() # start counter
+ count = counter.value() # read count, -32768..32767
+ counter.value(0) # reset counter
+ count = counter.value(0) # read and reset
+
+The PCNT hardware supports monitoring multiple pins in a single unit to
+implement quadrature decoding or up/down signal counters.
+
Software SPI bus
----------------