docs(pcnt): add gpio pull mode migration guide

Closes https://github.com/espressif/esp-idf/issues/18862
This commit is contained in:
Chen Jichang
2026-07-21 11:26:38 +08:00
parent cadfa9c096
commit 5ac3c30d5d
7 changed files with 44 additions and 9 deletions

View File

@@ -110,7 +110,7 @@ If a previously created PCNT channel is no longer needed, it is recommended to r
.. note::
In PCNT, the GPIOs involved can be reconfigured for pull-up or pull-down after initializing PCNT using functions such as :cpp:func:`gpio_pullup_en` and :cpp:func:`gpio_pullup_dis`.
The PCNT driver does not configure internal pull-up or pull-down resistors for the edge or level signal GPIOs. If your signal source needs a defined idle level, configure the GPIO pull mode explicitly with functions such as :cpp:func:`gpio_set_pull_mode`, :cpp:func:`gpio_pullup_en`, and :cpp:func:`gpio_pullup_dis`.
.. _pcnt-setup-channel-actions:
@@ -256,8 +256,12 @@ This function should be called when the unit is in the init state. Otherwise, it
The PCNT unit can receive a clear signal from the GPIO. The parameters that can be configured for the clear signal are listed in :cpp:type:`pcnt_clear_signal_config_t`:
- :cpp:member:`pcnt_clear_signal_config_t::clear_signal_gpio_num` specify the GPIO numbers used by **clear** signal. The default active level is high, and the input mode is pull-down enabled.
- :cpp:member:`pcnt_clear_signal_config_t::flags::invert_clear_signal` is used to decide whether to invert the input signal before it going into PCNT hardware. The invert is done by GPIO matrix instead of PCNT hardware. The input mode is pull-up enabled when the input signal is inverted.
- :cpp:member:`pcnt_clear_signal_config_t::clear_signal_gpio_num` specifies the GPIO number used by the **clear** signal. The default active level is high.
- :cpp:member:`pcnt_clear_signal_config_t::flags::invert_clear_signal` is used to decide whether to invert the input signal before it goes into PCNT hardware. The inversion is done by the GPIO matrix instead of PCNT hardware.
.. note::
The PCNT driver does not configure internal pull-up or pull-down resistors for the clear signal GPIO. If the clear signal requires a defined idle level, configure the GPIO pull mode explicitly with GPIO APIs.
This signal acts in the same way as calling :cpp:func:`pcnt_unit_clear_count`, but is not subject to software latency, and is suitable for use in situations with low latency requirements. Also please note, the flip frequency of this signal can not be too high.

View File

@@ -261,6 +261,11 @@ The legacy timer group driver ``driver/timer.h`` is deprecated since version 5.0
The legacy PCNT driver ``driver/pcnt.h`` is deprecated since version 5.0 (see :ref:`deprecate_pcnt_legacy_driver`). Starting from version 6.0, the legacy driver is completely removed. The new driver is placed in the :component:`esp_driver_pcnt`, and the header file path is ``driver/pulse_cnt.h``.
PCNT GPIO Pull-up/Pull-down Configuration
-----------------------------------------
The new PCNT driver no longer enables or disables internal pull-up/pull-down resistors on the GPIOs used for edge, level, or clear signals. If the input signal requires a defined idle level, configure the GPIO pull mode explicitly by calling the corresponding GPIO APIs.
.. only:: SOC_RMT_SUPPORTED
Legacy RMT Driver is Removed

View File

@@ -110,7 +110,7 @@ PCNT 单元和通道分别用 :cpp:type:`pcnt_unit_handle_t` 与 :cpp:type:`pcnt
.. note::
PCNT 中涉及到的 GPIO 都可以在初始化完 PCNT 后, 通过 :cpp:func:`gpio_pullup_en`:cpp:func:`gpio_pullup_dis` 等函数,重新进行上下拉等配置
PCNT 驱动不会为边沿信号或电平信号对应的 GPIO 配置内部上拉或下拉电阻。如果信号源需要确定的空闲电平,请使用 :cpp:func:`gpio_set_pull_mode`:cpp:func:`gpio_pullup_en`:cpp:func:`gpio_pullup_dis` 等函数显式配置 GPIO 上下拉模式
.. _pcnt-setup-channel-actions:
@@ -256,8 +256,12 @@ PCNT 单元的滤波器可滤除信号中的短时毛刺,:cpp:type:`pcnt_glitc
PCNT 单元的可以接收来自 GPIO 的清零信号,:cpp:type:`pcnt_clear_signal_config_t` 中列出了清零信号的配置参数:
- :cpp:member:`pcnt_clear_signal_config_t::clear_signal_gpio_num` 用于指定 **清零** 信号对应的 GPIO 编号。默认有效电平为高,使能下拉输入
- :cpp:member:`pcnt_clear_signal_config_t::flags::invert_clear_signal` 用于确定信号在输入 PCNT 之前是否需要被翻转,信号翻转由 GPIO 矩阵 (不是 PCNT 单元) 执行。驱动会使能上拉输入,以确保信号在未连接时保持高电平
- :cpp:member:`pcnt_clear_signal_config_t::clear_signal_gpio_num` 用于指定 **清零** 信号对应的 GPIO 编号。默认有效电平为高。
- :cpp:member:`pcnt_clear_signal_config_t::flags::invert_clear_signal` 用于确定信号在输入 PCNT 之前是否需要被翻转,信号翻转由 GPIO 矩阵不是 PCNT 单元)执行
.. note::
PCNT 驱动不会为清零信号对应的 GPIO 配置内部上拉或下拉电阻。如果清零信号需要确定的空闲电平,请使用 GPIO API 显式配置 GPIO 上下拉模式。
该输入信号的作用与调用 :cpp:func:`pcnt_unit_clear_count` 函数相同,但它不受软件延迟的限制,更适用于需要低延迟的场合。请注意,该信号的翻转频率不能太高。

View File

@@ -261,6 +261,11 @@ UART
旧版的 PCNT 驱动 ``driver/pcnt.h`` 在 5.0 的版本中就已经被弃用 (参考 :ref:`deprecate_pcnt_legacy_driver`)。从 6.0 版本开始,旧版驱动被完全移除。新驱动位于 :component:`esp_driver_pcnt` 组件中,头文件引用路径为 ``driver/pulse_cnt.h``
PCNT GPIO 上下拉配置
----------------------
新版 PCNT 驱动不再对边沿信号、电平信号或清零信号所使用的 GPIO 自动使能或关闭内部上拉/下拉电阻。如果输入信号需要确定的空闲电平,请调用相应的 GPIO API 显式配置 GPIO 的上下拉模式。
.. only:: SOC_RMT_SUPPORTED
旧版 RMT 驱动被移除