GithubHelp home page GithubHelp logo

Comments (5)

sisoteuz avatar sisoteuz commented on June 30, 2024

Seems the problem is more related to hardware than software (is_high function reads the register).

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 pin.internal_pull_up(true).

That might clear some doubts about the internal circuitry potentially affecting the results.

from esp-hal.

szubinskik avatar szubinskik commented on June 30, 2024

Well, with this simple schema:
obraz

turning the internal resistor on (pin.internal_pull_up(true)) does not change a thing.

from esp-hal.

bjoernQ avatar bjoernQ commented on June 30, 2024

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

pin1 = true
pin2 = true

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!

from esp-hal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.