-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unclear behaviour of GpioPin<Output<OpenDrain>, _>::is_high()
for ESP32
#1285
Comments
Seems the problem is more related to hardware than software ( Have you tried to set the internal pull up resistor in place of your own (which I assume is wired as a pull up). You can do so with That might clear some doubts about the internal circuitry potentially affecting the results. |
Ok let's try something even simpler #![no_std]
#![no_main]
use esp_backtrace as _;
use esp_hal::{clock::ClockControl, gpio::IO, peripherals::Peripherals, prelude::*};
use esp_println::println;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take();
let system = peripherals.SYSTEM.split();
let _clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let mut pin1 = io.pins.gpio4.into_open_drain_output();
pin1.internal_pull_up(true);
let mut pin2 = io.pins.gpio5.into_open_drain_output();
pin2.internal_pull_up(true);
pin1.set_high().unwrap();
pin2.set_high().unwrap();
println!("pin1 = {}", pin1.is_high().unwrap());
println!("pin2 = {}", pin2.is_high().unwrap());
loop {}
} This configures GPIO4 and 5 into open-drain and enables internal pull-ups. So for this test we just need to connect GPIO4 and 5. Running this code on e.g. EPS32-C3 and ESP32-S3 prints the expected
Setting any of the pins to low will show low for both - as expected. However, I can confirm it's always false on ESP32 - seems like a bug to me (on ESP32). Thanks for bringing this up! |
@szubinskik with #1315 merged it will hopefully work for you, additionally using another pin (which is not an RTC pin) should also help |
Thanks for your effort! Gonna verify this and close the issue in case it works |
Closing this, please let us know if your issue wasn't resolved @szubinskik :) |
Prerequisites:
Problem:
Plug the resistor to 3V and GPIO4 pins of the ESP module. Then consider the following code:
Obviously, there is voltage applied to the pin, yet the
is_high()
method returnsfalse
. Same setup, but forlet mut pin = io.pins.gpio4.into_floating_input();
printstrue
. Is this behaviour intended?The text was updated successfully, but these errors were encountered: