ESP32S3: PCNT: add support for all counting units #72933
Hallootto1100
started this conversation in
RFC
Replies: 1 comment
-
@sylvioalves could you have a look? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
ESP32: PCNT: add support for all counting units
Overview
The
ESP32-S3
features aPCNT
(Pulse Counter) peripheral containing 4 independent units, each with two channels, making it capable of interfacing with up to 4 quadrature encoders simultaneously.Current Status
I successfully configured the first unit and tested it with the qdec sample. While it's possible to define additional units in the device tree, no new device instances are created. Examining the current driver implementation reveals that it hardcodes channel 0, effectively limiting functionality to a single unit.
Additionally, the driver implements
SENSOR_CHAN_ROTATION
through the sensor API without performing any unit conversion to degrees, simply returning raw counter values.Root Cause
The fundamental limitation stems from the traditional sensor API's inability to support multiple channels of the same type within a single device. However, Zephyr's new Read and Decode API addresses this constraint by:
Although the Read and Decode API remains experimental, it's actively developed and approaching stability.
Proposed Solution:
Develop a new
PCNT
driver implementation that leverages the Read and Decode API's capabilities. The driver selection could be controlled viaCONFIG_SENSOR_ASYNC_API
, allowing users to choose between the legacy implementation (single unit) and the new multi-unit capable driver based on their requirements.This approach would unlock the
ESP32-S3
PCNT
peripheral's full potential while maintaining backward compatibility with existing applications.Beta Was this translation helpful? Give feedback.
All reactions