Page 1 of 1

RMT input pulls pin high

Posted: Mon Jun 02, 2025 6:56 pm
by floitsch_toit
I'm initializing an RMT peripheral as input. The moment I do that, the attached pin seems to pull up (as if it was configured as pull-up).
I haven't yet analyzed the exact value, but I can clearly see on my oscilloscope that the level of the pin is not 0 anymore.

What could be causing this? Is this expected behavior?
I have tried with two different ESP-IDF versions (5.3.1 and 5.4.1). The older one was worse (in that the pin seemed to pull even stronger).

Edit: looks like it's ~1M Ohm.

Re: RMT input pulls pin high

Posted: Tue Jun 03, 2025 8:23 am
by ahsrabrifat

Re: RMT input pulls pin high

Posted: Tue Jun 03, 2025 12:00 pm
by floitsch_toit
Thanks.
I have gone through these documents (multiple times...).

It doesn't explain why an RMT peripheral pulls up an input line. Maybe that's the expected behavior, but I'm pretty confident that older versions of the ESP-IDF didn't do that.

Re: RMT input pulls pin high

Posted: Tue Jun 03, 2025 12:36 pm
by ves011
Can you provide more details?
but I can clearly see on my oscilloscope that the level of the pin is not 0 anymore
Is it 1 or just floating? How did you read that 1MO? What is the ouput of gpio_dump_io_configuration()? Why does it bother you?

Re: RMT input pulls pin high

Posted: Wed Jun 04, 2025 3:36 pm
by floitsch_toit
Can you provide more details?
but I can clearly see on my oscilloscope that the level of the pin is not 0 anymore
Is it 1 or just floating? How did you read that 1MO? What is the ouput of gpio_dump_io_configuration()? Why does it bother you?
Thanks for the pointer to gpio_dump_io_configuration(). The RMT configuration does, indeed, set the pull-up flag. I will have to dig deeper, but I'm confident that my code isn't setting that flag.

Reason it bothers me: I'm using an HC-SR04 ultrasound sensor. Instead of using a voltage divider to go from 5V to 3.3V, I use the forward voltage drop of an LED to bring the level to the acceptable range. This also comes with the benefit that I have a visible indication of what the sensor is doing. (And tbh, it's just what I had on the table, whereas I would have needed to look for matching resistors). However, with the LED (being a diode), the HC-SR04 can't sink the pull-up anymore, and my pin now always read 1.

Edit: I added a dump before and after the rmt_new_rx_channel():

Code: Select all

    rmt_rx_channel_config_t cfg = {
      .gpio_num = static_cast<gpio_num_t>(pin_num),
      .clk_src = RMT_CLK_SRC_DEFAULT,
      .resolution_hz = resolution,
      .mem_block_symbols = static_cast<size_t>(block_symbols),
      .intr_priority = 0,
      .flags = {
        .invert_in = false,
        .with_dma = false,
        .io_loop_back = false,
      },
    };

    gpio_dump_io_configuration(stdout, 1ULL << pin_num);
    err = rmt_new_rx_channel(&cfg, &handle);
    gpio_dump_io_configuration(stdout, 1ULL << pin_num);
leads to

Code: Select all

================IO DUMP Start================
IO[19] -
  Pullup: 0, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 2 (GPIO)
  GPIO Matrix SigIn ID: (simple GPIO input)
  SleepSelEn: 1

=================IO DUMP End==================
================IO DUMP Start================
IO[19] -
  Pullup: 1, Pulldown: 0, DriveCap: 2
  InputEn: 1, OutputEn: 0, OpenDrain: 0
  FuncSel: 2 (GPIO)
  GPIO Matrix SigIn ID: 84
  SleepSelEn: 1

=================IO DUMP End==================
So the 'rmt_new_rx_channel' is setting the pullup.

Re: RMT input pulls pin high

Posted: Thu Jun 05, 2025 8:29 am
by MicroController
So the 'rmt_new_rx_channel' is setting the pullup.
Which makes sense, not setting up an input and letting it float by default...

Sounds like all you'll need is one gpio_set_pull_mode(static_cast<gpio_num_t>(pin_num), GPIO_PULLDOWN_ONLY) after initializing the RMT channel.

However, with the ~50kOhm of the internal pull-up/pull-down resistors, I guess you won't get a visible indication from the LED.

Re: RMT input pulls pin high

Posted: Fri Jun 06, 2025 8:32 am
by floitsch_toit
Espressif just removed the pullup and lets users configure the pin independently: https://github.com/espressif/esp-idf/co ... 0244f1c41b

However, with the ~50kOhm of the internal pull-up/pull-down resistors, I guess you won't get a visible indication from the LED.
I normally have an external pull-down resistor. For this one board is was just a relatively high one, which is why it conflicted with the pullup. And yes: in this case I wouldn't have seen anything. This LED configuration was just my goto-approach for the RC-SR04, since it doesn't need any specific resistor values.